Custom object data binding problem

Tags: #<Tag:0x00007f8b1d97d6a0>

Hi!
I have small problem with, data binding.
I have data in such format:

[{ id: 1, value: 'First', row: 0, col: 0, ...otherProps },
 { id: 2, value: 'Second', row: 0, col: 1, ...otherProps },
 { id: 3, value: 'Third', row: 1, col: 0, ...otherProps },
 { id: 4, value: 'Fourth', row: 1, col: 1, ...otherProps },
 ...etc.]

Can i create table with my custom row, col attributes?

Hi @mbdoy123,
Accordingly to our “Binding to data” section in our documentation, the dataset defined like that will be parsed as an array of objects. That means, { id: 1, value: 'First', row: 0, col: 0, ...otherProps } will be one row with the following columns [id, value, row, col, (otherProps' keys)].
properties like row, col, id or others you can store in CellMeta object (see cell/cells options).
Value has to be mapped as an array of arrays or an array of objects - as we mentioned in “Binding to data” documentation.

Thank you for answer!
But I wanted to know if we can set the coordinates of the cells, by the fields of our date;
For example:
We have a row in our data like

{id:1, row:0, col:1, value:'value', ...otherProps} 
can we make this object a cell:
   |    A   |   B    |
1  |        |  value |
2  |

I hope I asked the question correctly, thank you very much

Directly in that way, not. Although, if you know how many columns and rows you have, you can get/set your array of cells objects dynamically using modifyData hook.
We do not have yet any guide on how to use that hook, but you can preview how we use it in our Formula plugin here: https://github.com/handsontable/handsontable/blob/f513f882c0a28b2cbde48ae74a4fdf3ef00b6dd4/src/plugins/formulas/formulas.js#L583-L616

Got it!
Thank you

1 Like