i have a column with checkboxes in my datatable. The task is to check/uncheck all rows with shift+mouse click. is this possible?
Hello!
As a solution, you can redefine a click handler assigned to the common.checkbox()
.
on_click
provides the default click handlers for several elements in DataTable by their classes (docs).
For example, checkbox has a webix_table_checkbox
class.
As the event itself indicates whether a shift key was pressed, you can apply some custom/default logic depending on it.
https://webix.com/snippet/4f8c6557
thank you, this helps. but when I apply it to treetable with checkboxes both in parent and child rows, i receive error when using refresh()
[Error] TypeError: null is not an object (evaluating ‘e.row’)
webix_table_checkbox (vendor.min.js:18:19801)
iA (vendor.min.js:20:16894)
Yc (vendor.min.js:20:17714)
Sc (vendor.min.js:9:12640)
(анонимная функция) (vendor.min.js:4:24271)
and the following code in webix.js is highlighted:
webix_table_checkbox:function(t,e){e=this.locate(t);var i=this.getItem(e.row),
my code is:
$$(grid.id).on_click.sel_checkbox = function(ev, id){
if (ev.shiftKey) {
var checked = 0;
var shift_clicked = 0;
$$(grid.id).eachRow(
function (row){
var record = $$(grid.id).getItem(row);
if ( record.sel == 1) checked = 1;
if (record.id == id) shift_clicked = 1;
if (checked && (!shift_clicked || record.id == id)) record.sel = 1;
}
);
$$(grid.id).refresh();
}
}
Can you please provide a snippet of the issue? I may be missing something, but I can’t repeat this error