I have a handsontable
with the following data in it.
var data = [
["2008", 10, 11, 12, 1],
["2009", 20, 11, 14, 0],
["2010", 30, 15, 12, 1]
];
Link: FIDDLE
What I need suppose in last column if the value is 0 then I need the corresponding column containing row's second and third column make readonly.
Please note the following image for more detail:
Handontable Renderer method is what need to use. What I used is follows:
,
Handsontable.hooks.add('afterRender', function () {
var a = $('.htCore').find('tbody tr td:nth-child(2)');
var b = $('.htCore').find('tbody tr td:nth-child(3)');
var g = $('.htCore').find('tbody tr td:nth-child(4)');
g.each(function (i, v) {
if (parseFloat(g.eq(i).text()) == 0)) {
a.eq(i).attr('readonly',true);
b.eq(i).attr('readonly',true);
});
But not working please guide me....
You don't need to use JQuery to update readOnly attribute.
You need to create a cell properties like my example :
cells: function (row, col, prop) {
var cellProperties = {};
var hot = this.instance;
if((col == 2 || col == 3) && hot.getDataAtCell(row, hot.colToProp(4)) == 0) {
cellProperties.readOnly = true;
} else {
cellProperties.readOnly = false;
}
return cellProperties;
}
Regards