Skip to content

Commit 0cce063

Browse files
committed
Added search box
1 parent cf412f0 commit 0cce063

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

src/assets/js/indicatorSetsTable.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function calculate_table_height() {
1212

1313
var table = new DataTable("#indicatorSetsTable", {
1414
fixedHeader: true,
15-
searching: false,
15+
searching: true,
1616
paging: false,
1717
scrollCollapse: true,
1818
scrollX: true,
@@ -23,25 +23,29 @@ var table = new DataTable("#indicatorSetsTable", {
2323
},
2424
ordering: false,
2525
mark: true,
26-
27-
language: {
28-
buttons: {
29-
colvis: "Toggle Columns",
30-
},
31-
},
26+
// language: {
27+
// buttons: {
28+
// colvis: "Toggle Columns",
29+
// },
30+
// },
31+
dom: 'lrtip' // Hides the default search box
3232
});
3333

34-
new DataTable.Buttons(table, {
35-
buttons: [
36-
{
37-
extend: "colvis",
38-
columns: "th:nth-child(n+3)",
39-
prefixButtons: ["colvisRestore"],
40-
},
41-
],
42-
});
34+
// new DataTable.Buttons(table, {
35+
// buttons: [
36+
// {
37+
// extend: "colvis",
38+
// columns: "th:nth-child(n+3)",
39+
// prefixButtons: ["colvisRestore"],
40+
// },
41+
// ],
42+
// });
4343

44-
table.buttons(0, null).container().appendTo("#colvis");
44+
// table.buttons(0, null).container().appendTo("#colvis");
45+
46+
$('#myCustomSearchBox').on('keyup change', function() {
47+
table.search(this.value).draw();
48+
});
4549

4650
function format(indicatorSetId, relatedIndicators, indicatorSetDescription) {
4751
var indicators = relatedIndicators.filter(

src/templates/indicatorsets/indicatorSetsFilters.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@
1010
<div class="colvis" id="colvis"></div>
1111
<h2 class="card-title font-size-25">Filters</h2>
1212
<div class="accordion accordion-flush" id="accordionIndicatorSetFilters">
13+
<div class="accordion-item">
14+
<p class="accordion-header" id="flush-heading_search">
15+
Search:
16+
<a tabindex="0"
17+
type="button"
18+
class="info-button filter-description-popover"
19+
data-mdb-container="body"
20+
data-mdb-ripple-init
21+
data-mdb-popover-init
22+
data-mdb-trigger="hover"
23+
data-mdb-placement="right"
24+
data-mdb-content="{{ filters_descriptions|dict_get:"" }}">
25+
<i class="far fa-circle-question"></i>
26+
</a>
27+
</p>
28+
<div id="flush-collapse_search"
29+
aria-labelledby="flush-heading_search"
30+
data-mdb-parent="#accordionIndicatorSetFilters">
31+
<div class="accordion-body margin-top-1rem">
32+
<div class="input-group">
33+
<div class="form-outline" data-mdb-input-init>
34+
<input type="text"
35+
id="myCustomSearchBox"
36+
class="form-control form-control-lg" />
37+
<label class="form-label" for="form12">Search ...</label>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</div>
1343
<div class="accordion-item">
1444
<p class="accordion-header" id="flush-heading_location_search">
1545
Location(s):

0 commit comments

Comments
 (0)