Hi,
I’m trying to instantiate HOT with metas.
But the only way I found is to instantiate first without metas and loop into the metas to use setCellMeta.
I don’t think it’s a good idea cause if I don’t make a mistake, It’s rendering every time I use setCellMeta.
Am I right ?
Can you please explain me how to instantiate in the settings the metas ?
Have a nice day,
HeyHeyChicken
Hey, it’s nice to see you again.
Usually, we recommend cell
or cells
method, but some of the meta can be added to columns
. Can you share more details where and what you’d like to add?
Nice to see you too,
That’s an example: JSFiddle.
As you can see, I used cells prop to set colors to orange for all of my cells. So as I expected, all of the cells are orange. I tryed to use setCellMetaObject
after initialisation, but can’t change my color attribute … made I a mistake ?
Thx.
The safest way to change everything related to CSS is by attaching a className
. So you’d need to add 3 new classes
body .handsontable .orange {
background: orange;
}
body .handsontable .red {
background: red;
}
body .handsontable .green {
background: green;
}
Thanks for your help, but my problem isn’t to set style. The style is just here to debug and see if my meta change.
Please have a look at this new example : JSFiddle.
I used attr (not class to prevent have multiple color per cell) and no style. I’ve got the same problem.
And with the cells
solution, I can have problems. If the base data is modified.
In the example this is simulated by waiting 5 sec.
I just need to init a HOT with metas and be able to edit theses meta after init.
I’ve simplified the example https://jsfiddle.net/9tm18kzj/ and realised that we had a similar report some time ago. I’ll check that out and get back with feedback.
Quick update.
The cells
are called by the setCellMeta
so it overwrites the setCellMeta
. We can stop it by adding a condition to set the value by cells only if it hasn’t been defined in the first place
Updated example https://jsfiddle.net/5f79bk6w/
Does it help?
Thx for your simplified example. But if I don’t make a mistake, the value of the meta is never equals to “MyFirstRow”. Am I wrong ?
Sorry, old demo. Here’s the new one https://jsfiddle.net/gt1x3Lfd/
That’s perfect 
An other small question please ( a little one
)
What about if I need to get all of the metas like this :
[
[
{“meta_A”: “value_A”, “meta_B”: “value_B”},
{“meta_C”: “value_C”, “meta_D”: “value_D”},
…
],
…
]
Does HOT have a function like “instace.getAllMetas()” to get that ?
Thx.