Handsontable select/unselect all rows on clicking checkbox of header in handsontable(s) on a page

1,264 views
Skip to first unread message

karunes...@gmail.com

unread,
Oct 24, 2017, 8:08:45 AM10/24/17
to Handsontable
Hello there,
I have multiple (dynamic number of handsontables) handsontables on a single page. And each table have checkboxes in last column, I need functionality to select/unselect checkboxes inside header of a table and rest checkboxes of that particular table should checked/unchecked respectively.

My code is like below:
$( multiTableArray ).each(function( i , v) {
var $container = $("#hot_"+i);
$container.handsontable({
data:myData,
columns: colls,
stretchH: 'all',
autoWrapRow: true,
contextMenu: ['row_above', 'row_below', 'remove_row'],
colHeaders: colHeaders,
colHeaders: function (col) {
var colHeaderName = colHeaders[col];
switch (colHeaderName) {
case "addLine":
var txt = "<input type='checkbox' data='"+i+"'class='checker' ";
txt += isChecked(myData) ? 'checked="checked"' : '';
txt += ">";
return txt;
default:
return colHeaders[col];
}
},
});
$container.on('mouseup', 'input.checker', function (event) {
var current = !$('#containerID input.checker').is(':checked');
var id = $(this).attr('data');
$(myData).each(function( myDataIndex , myDataVal) {
myDataVal.addLine = current;
myData[myDataIndex] = myDataVal;
})
$container.handsontable('render');
});
})


This code is solving my problem to checked/unchecked all checkboxes on cclicking checkbox inside header of a particular table. But if one table have all checkbox checked then header checkbox of rest other tables does not work untill i uncheck the previously checked one.

Please suggest if i am doing it wrong way, also please help how resolving the issue.

Reply all
Reply to author
Forward
0 new messages