Search code examples
handsontable

updatesettings does not work in Handsontable for columns


I'm trying to update column's setting in Handsontable like this:

 var newColumnSettings = [{ data: 0, readOnly: true }, { data: 1 }, { data: 2 }, { data: 3 }, { data: 4, readOnly: true }];

 $('#container').handsontable('updateSettings', { columns: newColumnSettings });

But it simply does not work and nothing happens, and handsontable still shows the older columns.

Should I do something before or after? Am I doing something wrong?

Thanks in advance.


Solution

  • Have you tried to rerender the table after your updateSettings?

    var newColumnSettings = [{ data: 0, readOnly: true }, { data: 1 }, { data: 2 }, { data: 3 }, { data: 4, readOnly: true }];
    
    var ht = $('#container').handsontable('getInstance');
    ht.updateSettings({ columns: newColumnSettings });
    ht.render();
    

    See if that helps