Skip to content

Commit 9853b20

Browse files
committed
Add Datataables searchBuilder
1 parent 93457f5 commit 9853b20

File tree

5 files changed

+105
-4
lines changed

5 files changed

+105
-4
lines changed

assets/src/legacy/attributeTable.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
import DataTable from 'datatables.net-bs5';
9+
import 'datatables.net-buttons-bs5';
10+
import DateTime from 'datatables.net-datetime';
11+
import 'datatables.net-searchbuilder-bs5';
912
import DOMPurify from 'dompurify';
1013
import '../images/svg/filter-square.svg';
1114

@@ -1469,6 +1472,28 @@ var lizAttributeTable = function() {
14691472
}
14701473
});
14711474

1475+
// Add searchBuilder button
1476+
// Disable live search to avoid searching on each keystroke
1477+
// Only display columns that are sortable for search
1478+
const searchBuilderButton = new DataTable.Buttons(oTable, {
1479+
buttons: [
1480+
{
1481+
extend: 'searchBuilder',
1482+
config: {
1483+
liveSearch: false,
1484+
columns: '.dt-orderable-asc'
1485+
}
1486+
}
1487+
]
1488+
});
1489+
1490+
// Attach searchBuilder button to attribute-layer-action-bar
1491+
const actionBar = document.querySelector(aTable)
1492+
.closest('.attribute-layer-content')
1493+
.previousElementSibling;
1494+
1495+
actionBar.insertAdjacentElement('afterbegin', searchBuilderButton.container()[0]);
1496+
14721497
// Unbind previous events on page
14731498
oTable.on( 'page', function() {
14741499
// unbind previous events
@@ -1521,7 +1546,7 @@ var lizAttributeTable = function() {
15211546
data: "lizSelected",
15221547
width: "25px",
15231548
searchable: false,
1524-
sortable: true,
1549+
sortable: false,
15251550
visible: false
15261551
});
15271552
firstDisplayedColIndex+=1;

0 commit comments

Comments
 (0)