I have a Handsontable
as follows:
ordertable = new Handsontable(container, {
data: data,
colHeaders: ['Customer', 'Mode', 'Remarks', 'Due', 'Recieved'],
columns: [{
data: 2,
readOnly: true
}, {
data: 6,
type: 'autocomplete',
source: collectionmethod,
validator: collectionmethod_validations,
strict: true
}, {
data: 5,
readOnly: false
}, {
data: 4,
readOnly: true,
type: 'numeric',
format: '0.00'
}, {
data: 3,
type: 'numeric',
format: '0.00',
validator: amt_validations,
allowInvalid: true
}],
minSpareRows: 0,
rowHeaders: true,
contextMenu: ['row_above', 'row_below', 'remove_row', 'undo', 'redo'],
colWidths: [150, 100, rest, 100, 100],
autoWrapRow: true,
autoWrapCol: true,
beforeRemoveRow: removerow_validation
});
I have a checkbox. And when I click checkbox the value of Due
(4th column) should be populated to the 'Recieved'(column). If I uncheck it then the Received
should be blank which is same as table onload.
What I do is as follows:
$("#sel_prefill").click(function() {
if ($("#sel_prefill:checked").val()) {
var g = $('.htCore').find('tbody tr td:nth-child(5)'); //Due
var f = $('.htCore').find('tbody tr td:nth-child(6)') // Recieved
g.each(function(i, v) {
f.eq(i).text(g.eq(i).text());
$(v).css({
'text-align': 'right'
});
});
} else {
var g = $('.htCore').find('tbody tr td:nth-child(5)'); //Due
var f = $('.htCore').find('tbody tr td:nth-child(6)') // Recieved
g.each(function(i, v) {
f.eq(i).text("");
//$container.handsontable('setDataAtCell', 1, 4, 5);
$(v).css({
'text-align': 'right'
});
});
}
});
It is working fine.
But the problem is that after checking checbox the value the value of 4the column is populated to 5th. But if I edit any cell from 5th column, then the entire column except editted cell gets refreshed and 5th column becomes blank.
.
How can I avoid it.
Please refer the pics for step by step details:
How can I avoid refresh the cells after editing?