Skip to content

Commit f1008e7

Browse files
committed
feat: Enable per-column filtering
Fixes #109
1 parent 2fcd6ae commit f1008e7

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

app/assets/javascripts/manage/lib/datatables.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// Global settings and initializer
22

3+
function setupFooterSearch(table) {
4+
table.columns().every(function() {
5+
var column = this;
6+
$(':input', column.footer()).on('keyup change', function() {
7+
var input = this;
8+
if (column.search() !== input.value) {
9+
column.search(input.value).draw();
10+
}
11+
});
12+
});
13+
}
14+
315
$.extend($.fn.dataTable.defaults, {
416
processing: true,
517
serverSide: true,
@@ -14,6 +26,7 @@ $.extend($.fn.dataTable.defaults, {
1426
.buttons()
1527
.container()
1628
.appendTo($('.col-md-6', table.table().container()).first());
29+
setupFooterSearch(table);
1730
},
1831
pagingType: 'full_numbers',
1932
lengthChange: false,

app/views/manage/questionnaires/index.html.haml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,38 @@
2424
%th Dietary restrictions
2525
%th Special needs
2626
%tbody
27+
%tfoot
28+
%tr
29+
%th
30+
%th
31+
%th
32+
%th
33+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'ID'}
34+
%th
35+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'First name'}
36+
%th
37+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Last name'}
38+
%th
39+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Email'}
40+
%th
41+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Phone'}
42+
%th
43+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Gender'}
44+
%th
45+
%th
46+
%select.form-control.form-control-sm
47+
%option{value: ''} Status
48+
- Questionnaire::POSSIBLE_ACC_STATUS.each do |key, value|
49+
%option{value: key}= value
50+
%th
51+
%th
52+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'School'}
53+
%th
54+
%th
55+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Dietary restrictions'}
56+
%th
57+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Special needs'}
58+
2759
2860
.row
2961
.col-sm-7.col-lg-6

app/views/manage/schools/index.html.haml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@
1111
%th State
1212
%th Count
1313
%tbody
14+
%tfoot
15+
%tr
16+
%th
17+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'ID'}
18+
%th
19+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'Name'}
20+
%th
21+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'City'}
22+
%th
23+
%input.form-control.form-control-sm{autocomplete: 'off', placeholder: 'State'}

0 commit comments

Comments
 (0)