populateFromArray

Tags: #<Tag:0x00007f8b1d45a510>

Hi Aleksandra,

Please can you share how we can use populateFromArray method, I am using this syntax

    hotInstance.populateFromArray(1, 1,[[1], [2], [1], [2], [1], [2]]);

to update from 2nd row’s 2nd column till the 2nd column of 7th row.

But I am getting some error by using this method, Please can you help out?

Error:- TypeError: changes[i][3].trim is not a function

Hey @preet.saxena

I guess that it depends on your dataset and structure. Here https://jsfiddle.net/handsoncode/mno80pdv/ it works well.

Can you share a dmeo?

Thanks,
Its working after converting my input to string and error is not appearing.

Can I use populate from array with the readOnly column?

No, if the cell is marked as readOnly you cannot change it.
Example https://jsfiddle.net/handsoncode/avy654m9/

If you wish to block user from editing the changes but want to get the populating you can turn off the editor https://jsfiddle.net/handsoncode/1z4Lra8y/

Thaks Aleksandra,

But the editor will allow the data to paste so What I am thinking about the solution for this is that we can just turn on the readonly property before populateFromArray and after the execution of its turn off the read-only property.

If you want to cancel pasting you can use the beforePaste hook. Here’s a demo that cancel some changes https://handsontable.com/docs/7.0.2/Hooks.html#event:beforePaste