Hi!
First, thanks for the awesome library, it works like a charm for me
My case: I have complexe javascript objects that serve as row data. Each column corresponds to an attribute in these objects.
// A row object example
const myFirstRow = {
header1: { someProp: true, otherProp: 123, value: 'hello world' },
header2: { someProp: false, otherProp: 0, value: 'goodbye' },
}
// columns option looks like this. The code is simplified for clarity.
columns: [{
data: `header1.value`,
},
{
data: `header2.value`,
}]
The value
attribute in my columns is the property I expect to be rendered in the cells. It works great this way.
But I want my other properties (like someProp: true, otherProp: 123
) to be part of the cell properties (meta data).
What I’ve tried so far:
- Currently, I’m using the
cells
hook with a function to set it up. I usegetSourceDataAtRow()
to get my entire object for the row (myFirstRow
), then get the corresponding column (header1
) within it and return that in thecells
function. It works, but this hook is called whenever a cell is rendered, thus its metadata resets everytime! - I want it to be set once for all at init for example, but by using such hooks, I have to manually iterate through all my columns + rows to get the data and call
setCellMetaObject
for each cell. It’s costly and I feel like it’s not the proper way to do this.
Do you have any idea to accomplish this in a clean way?