Skip to content

Commit 5f3b056

Browse files
authored
MultiselectColumn: updateCheckAll on table redraw + enable/disable action buttons
1 parent 5a538b5 commit 5f3b056

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Resources/views/datatable/multiselect_actions.html.twig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,31 @@ function updateCheckAll() {
9090
var cbox_all = $("#sg-datatables-{{ datatable_name }} tbody input.sg-datatables-{{ datatable_name }}-multiselect-checkbox:checkbox");
9191
var cbox_checked = $("#sg-datatables-{{ datatable_name }} tbody input.sg-datatables-{{ datatable_name }}-multiselect-checkbox:checkbox:checked");
9292
var cbox_checkall = $("#sg-datatables-{{ datatable_name }} input.sg-datatables-{{ datatable_name }}-multiselect-checkall:checkbox");
93+
var action_links = $(".sg-datatables-{{ datatable_name }}-multiselect-action");
9394

9495
if(cbox_checked.length === 0){
9596
cbox_checkall.prop('checked', false);
9697
cbox_checkall.prop('indeterminate', false);
98+
action_links.prop('disabled', true);
99+
action_links.addClass('disabled');
97100
} else if (cbox_checked.length === cbox_all.length){
98101
cbox_checkall.prop('checked', true);
99102
cbox_checkall.prop('indeterminate', false);
103+
action_links.prop('disabled', false);
104+
action_links.removeClass('disabled');
100105
} else {
101106
cbox_checkall.prop('checked', false);
102107
cbox_checkall.prop('indeterminate', true);
108+
action_links.prop('disabled', false);
109+
action_links.removeClass('disabled');
103110
}
104111
}
105112

113+
{# handle table redraw #}
114+
$("#sg-datatables-{{ datatable_name }}").on("draw.dt", function () {
115+
updateCheckAll();
116+
});
117+
106118
{# handle row <tr> click #}
107119
$("#sg-datatables-{{ datatable_name }} tbody").on("click", "tr", function () {
108120
{# add 'selected' class #}
@@ -137,6 +149,7 @@ $("#sg-datatables-{{ datatable_name }}").on("click", "input.sg-datatables-{{ dat
137149
}
138150
}
139151
});
152+
updateCheckAll();
140153
});
141154

142155
{# handle multiselect action click #}

0 commit comments

Comments
 (0)