@@ -258,13 +258,6 @@ var lizAttributeTable = function() {
258258 dTable . draw ( ) ;
259259 } ) ;
260260 } ) ;
261-
262- // Bind click on tabs to resize datatable tables
263- $ ( '#attributeLayers-tabs li' ) . click ( function ( ) {
264- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
265- refreshDatatableSize ( '#' + mycontainerId ) ;
266- } ) ;
267-
268261 } else {
269262 // Hide navbar menu
270263 $ ( '#mapmenu li.attributeLayers' ) . hide ( ) ;
@@ -501,12 +494,6 @@ var lizAttributeTable = function() {
501494 // Action bar specific to the tab
502495 html += '<div class="attribute-layer-action-bar">' ;
503496
504- // Search input
505- html += '<div class="btn-group">' ;
506- html += ' <input id="attribute-layer-search-' + cleanName + '" type="search" class="form-control" placeholder="' + lizDict [ 'attributeLayers.toolbar.input.search.title' ] + '">' ;
507- html += ' <i class="clear-layer-search icon-remove" style="position:absolute;right:4px;top:4px;cursor:pointer;"></i>' ;
508- html += '</div>' ;
509-
510497 // Selected searched lines button
511498 html += '<button class="btn-select-searched btn btn-sm" value="' + cleanName + '" title="' + lizDict [ 'attributeLayers.toolbar.btn.select.searched.title' ] + '"><i class="icon-star"></i></button>' ;
512499
@@ -652,22 +639,12 @@ var lizAttributeTable = function() {
652639 $ ( tabContentId ) . remove ( ) ; //remove respective tab content
653640 } ) ;
654641
655- if ( childHtml ) {
656-
657- // Bind adjust child columns when children tab visibility change
658- $ ( '#attribute-layer-' + cleanName + ' div.attribute-layer-child-content ul li a[data-toggle="tab"]' ) . on ( 'shown.bs.tab' , function ( e ) {
659- var target = $ ( e . target ) . attr ( "href" ) // activated tab
660- var dtable = $ ( target ) . find ( 'table.dataTable' ) ;
661- dtable . DataTable ( ) . tables ( ) . columns . adjust ( ) ;
662- } ) ;
663- }
664-
665642 if ( childHtml ) {
666643 $ ( '#attribute-layer-' + cleanName + ' button.btn-toggle-children' )
667644 . click ( function ( ) {
668645 var parentDir = $ ( this ) . parents ( 'div.attribute-layer-main' ) ;
669646 parentDir . find ( 'div.attribute-layer-content' ) . toggleClass ( 'showChildren' ) ;
670- parentDir . find ( 'div.tabbable. attribute-layer-child-content' ) . toggle ( ) ;
647+ parentDir . find ( 'div.attribute-layer-child-content' ) . toggle ( ) ;
671648 // Refresh parent table size
672649 refreshDatatableSize ( '#attribute-layer-main-' + cleanName ) ;
673650 return false ;
@@ -683,8 +660,6 @@ var lizAttributeTable = function() {
683660 $ ( '#attribute-layer-main-' + cleanName ) . toggleClass ( 'reduced' , ! $ ( this ) . hasClass ( 'btn-primary' ) ) ;
684661 $ ( '#attribute-table-panel-' + cleanName ) . toggleClass ( 'visible' , ! $ ( this ) . hasClass ( 'btn-primary' ) ) ;
685662 $ ( this ) . toggleClass ( 'btn-primary' ) ;
686-
687- refreshDatatableSize ( '#attribute-layer-main-' + cleanName ) ;
688663 return false ;
689664 } ) ;
690665 }
@@ -1387,28 +1362,12 @@ var lizAttributeTable = function() {
13871362
13881363 lConfig [ 'alias' ] = cAliases ;
13891364 // Datatable configuration
1390- if ( ! $ . fn . dataTable . isDataTable ( aTable ) ) {
1391- // Search while typing in text input
1392- // Deactivate if too many items
1393- var searchWhileTyping = true ;
1394-
1395- var myDom = '<<t>ipl>' ;
1396- if ( searchWhileTyping ) {
1397- $ ( '#attribute-layer-search-' + cleanName ) . on ( 'keyup' , function ( e ) {
1398- var searchVal = this . value ;
1399- lizdelay ( function ( ) {
1400- oTable . fnFilter ( searchVal ) ;
1401- } , 500 ) ;
1402- } ) ;
1403- } else {
1404- myDom = '<<t>ipl>' ;
1405- }
1406-
1365+ if ( ! DataTable . isDataTable ( aTable ) ) {
14071366 const datatablesUrl = globalThis [ 'lizUrls' ] . wms . replace ( 'service' , 'datatables' ) ;
14081367 const params = globalThis [ 'lizUrls' ] . params ;
14091368 params [ 'layerId' ] = lConfig . id ;
14101369
1411- $ ( aTable ) . dataTable ( {
1370+ const oTable = new DataTable ( aTable , {
14121371 serverSide : true
14131372 , ajax : {
14141373 url : datatablesUrl + '?' + new URLSearchParams ( params ) . toString ( ) ,
@@ -1468,17 +1427,17 @@ var lizAttributeTable = function() {
14681427 }
14691428 }
14701429 , columns : columns
1471- , initComplete : function ( settings , json ) {
1472- const api = new $ . fn . dataTable . Api ( settings ) ;
1473- const tableId = api . table ( ) . node ( ) . id ;
1474- const featureType = tableId . split ( 'attribute-layer-table-' ) [ 1 ] ;
1430+ , initComplete : function ( settings ) {
1431+ // Refresh size of datatable after data has been loaded
1432+ refreshDatatableSize ( '#' + $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ) ;
14751433
14761434 // Trigger event telling attribute table is ready
1477- lizMap . events . triggerEvent ( "attributeLayerContentReady" ,
1478- {
1479- 'featureType' : featureType
1480- }
1481- ) ;
1435+ const tableId = settings . api . table ( ) . node ( ) . id ;
1436+ const featureType = tableId . split ( 'attribute-layer-table-' ) [ 1 ] ;
1437+
1438+ lizMap . events . triggerEvent ( "attributeLayerContentReady" , {
1439+ 'featureType' : featureType ,
1440+ } ) ;
14821441 }
14831442 , order : [ [ firstDisplayedColIndex , "asc" ] ]
14841443 , language : { url :globalThis [ 'lizUrls' ] [ "dataTableLanguage" ] }
@@ -1496,43 +1455,35 @@ var lizAttributeTable = function() {
14961455 thumbnail . setAttribute ( 'src' , lizUrls . media + '?repository=' + lizUrls . params . repository + '&project=' + lizUrls . params . project + '&path=' + thumbnail . dataset . src ) ;
14971456 }
14981457 }
1499- , dom : myDom
15001458 , pageLength : 50
1501- , scrollY : '95%'
1502- , scrollX : '100%'
1503- } ) ;
1504-
1505- var oTable = $ ( aTable ) . dataTable ( ) ;
1506-
1507- if ( ! searchWhileTyping )
1508- $ ( '#attribute-layer-search-' + cleanName ) . hide ( ) ;
1509-
1510- // Bind button which clears top-left search input content
1511- $ ( '#attribute-layer-search-' + cleanName ) . next ( '.clear-layer-search' ) . click ( function ( ) {
1512- $ ( '#attribute-layer-search-' + cleanName ) . val ( '' ) . focus ( ) . keyup ( ) ;
1459+ , scrollY : '95%' // Used to init but refreshDatatableSize() does the job of setting the height
1460+ , layout : {
1461+ topStart : null ,
1462+ topEnd : null ,
1463+ bottomStart : [ 'info' , 'pageLength' ] ,
1464+ bottomEnd : {
1465+ paging : {
1466+ firstLast : false
1467+ }
1468+ } ,
1469+ }
15131470 } ) ;
15141471
15151472 // Unbind previous events on page
1516- $ ( aTable ) . on ( 'page.dt ' , function ( ) {
1473+ oTable . on ( 'page' , function ( ) {
15171474 // unbind previous events
15181475 $ ( aTable + ' tr' ) . unbind ( 'click' ) ;
15191476 $ ( aTable + ' tr td button' ) . unbind ( 'click' ) ;
15201477 } ) ;
15211478
15221479 // Bind events when drawing table
1523- $ ( aTable ) . on ( 'draw.dt ' , function ( ) {
1480+ oTable . on ( 'draw' , function ( ) {
15241481
15251482 $ ( aTable + ' tr' ) . unbind ( 'click' ) ;
15261483 $ ( aTable + ' tr td button' ) . unbind ( 'click' ) ;
15271484
15281485 // Bind event when users click anywhere on the table line to highlight
15291486 bindTableLineClick ( aName , aTable ) ;
1530-
1531- // Refresh size
1532- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
1533-
1534- refreshDatatableSize ( '#' + mycontainerId ) ;
1535-
15361487 return false ;
15371488
15381489 } ) ;
@@ -1547,8 +1498,6 @@ var lizAttributeTable = function() {
15471498 lizMap . mainLizmap . edition . fetchEditableFeatures ( [ lConfig . id ] ) ;
15481499 }
15491500
1550- refreshDatatableSize ( '#' + $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) )
1551-
15521501 if ( aCallback )
15531502 aCallback ( aName , aTable ) ;
15541503
@@ -2069,7 +2018,7 @@ var lizAttributeTable = function() {
20692018 var tableLayerName = $ ( this ) . parents ( 'div.dataTables_wrapper:first' ) . prev ( 'input.attribute-table-hidden-layer' ) . val ( )
20702019 // Get parent table for the feature type
20712020 if ( tableLayerName
2072- && $ . fn . dataTable . isDataTable ( $ ( this ) )
2021+ && DataTable . isDataTable ( $ ( this ) )
20732022 && lizMap . cleanName ( featureType ) == tableLayerName
20742023 ) {
20752024
@@ -2932,7 +2881,7 @@ var lizAttributeTable = function() {
29322881 var tableLayerName = $ ( this ) . parents ( 'div.dataTables_wrapper:first' ) . prev ( 'input.attribute-table-hidden-layer' ) . val ( )
29332882
29342883 if ( tableLayerName
2935- && $ . fn . dataTable . isDataTable ( $ ( this ) )
2884+ && DataTable . isDataTable ( $ ( this ) )
29362885 && lizMap . cleanName ( featureType ) == tableLayerName
29372886 ) {
29382887 var zTable = '#' + tableId ;
@@ -3039,14 +2988,10 @@ var lizAttributeTable = function() {
30392988 var h = $ ( container + ' div.attribute-layer-content' ) . height ( ) ? $ ( container + ' div.attribute-layer-content' ) . height ( ) : 0 ;
30402989
30412990 h -= $ ( container + ' thead' ) . height ( ) ? $ ( container + ' thead' ) . height ( ) : 0 ;
3042- h -= $ ( container + ' div.dataTables_paginate' ) . height ( ) ? $ ( container + ' div.dataTables_paginate' ) . height ( ) : 0 ;
3043- h -= $ ( container + ' div.dataTables_filter' ) . height ( ) ? $ ( container + ' div.dataTables_filter' ) . height ( ) : 0 ;
3044- h -= 20 ;
3045-
3046- dtable . parent ( 'div.dataTables_scrollBody' ) . height ( h ) ;
2991+ h -= $ ( container + ' div.dt-paging' ) . height ( ) ? $ ( container + ' div.dt-paging' ) . height ( ) : 0 ;
2992+ h -= 25 ;
30472993
3048- // Width : adapt columns size
3049- dtable . DataTable ( ) . tables ( ) . columns . adjust ( ) ;
2994+ dtable . parent ( 'div.dt-scroll-body' ) . height ( h ) ;
30502995 }
30512996
30522997 /**
@@ -3525,41 +3470,15 @@ var lizAttributeTable = function() {
35253470 }
35263471 } ,
35273472
3528- bottomdocksizechanged : function ( evt ) {
3473+ bottomdocksizechanged : function ( ) {
35293474 var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
35303475 refreshDatatableSize ( '#' + mycontainerId ) ;
3531- } ,
3532- dockopened : function ( evt ) {
3533- if ( $ ( '#mapmenu li.attributeLayers' ) . hasClass ( 'active' ) ) {
3534- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
3535- refreshDatatableSize ( '#' + mycontainerId ) ;
3536- }
3537- } ,
3538- dockclosed : function ( evt ) {
3539- if ( $ ( '#mapmenu li.attributeLayers' ) . hasClass ( 'active' ) ) {
3540- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
3541- refreshDatatableSize ( '#' + mycontainerId ) ;
3542- }
3543- } ,
3544- rightdockopened : function ( evt ) {
3545- if ( $ ( '#mapmenu li.attributeLayers' ) . hasClass ( 'active' ) ) {
3546- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
3547- refreshDatatableSize ( '#' + mycontainerId ) ;
3548- }
3549- } ,
3550- rightdockclosed : function ( evt ) {
3551- if ( $ ( '#mapmenu li.attributeLayers' ) . hasClass ( 'active' ) ) {
3552- var mycontainerId = $ ( '#bottom-dock div.bottom-content.active div.attribute-layer-main' ) . attr ( 'id' ) ;
3553- refreshDatatableSize ( '#' + mycontainerId ) ;
3554- }
35553476 }
3556-
35573477 } ) ; // lizMap.events.on end
35583478
35593479 // Extend lizMap API
35603480 lizMap . getAttributeFeatureData = getAttributeFeatureData ;
35613481
35623482 } // uicreated
35633483 } ) ;
3564-
35653484} ( ) ;
0 commit comments