I am trying to set some cell meta for any newly created cells using the “insert row” functionality. The problem is summarized in this simplified jsFiddle:
http://jsfiddle.net/s6t768pq/1010/
If you insert a new row, the setDataAtCell()
will work and set the correct cell’s data. However, if I try to set the cell’s meta (in the following line) for the same cell, it sets the meta to the cell after it. I tried changing it to index-1
, but that made it set the meta to the cell above it.
It seems like setCellMeta()
can’t “see” the newly created row when called in the hook’s callback, while setDataAtCell()
can.
What should I do to set the cell’s meta inside the afterCreateRow
hook?
setCellMeta doesn't work properly in afterCreateRow hook
It is also worth noting that it worked as expected when I delayed the setCellMeta()
function by putting it in the javascript setTimeout()
function:
http://jsfiddle.net/s6t768pq/1013/
Thank you for sharing the demo. I will test it and get back to you tomorrow.
Hi @aabounegm
thank you for sharing the demo and sorry for a delay.
You are right. It seems like the order of operations is incorrect. I guess that we are calling the callbacks in the wrong order. Thankfully we can set the delay to something unnoticeable for a human eye.
I am making this issue as a bug
Thank you for your answer.
So basically, until an update rolls out, I should keep the temporary workaround of setTimeout()
, right? What number do you suggest I put there?
Yes, it’s currently the best way to achieve this goal.
when it comes to delay - the lower the better. I can see that 3ms are working fine.
Alright, thank you very much.
You can mark this thread closed if you want
I will keep it open till we investigate the subject.
Maybe it is not the best demo but I really wanted to keep it simple. Here http://jsfiddle.net/650pjyng/ I am adding a className
via setCellMeta
method in the afterCreateRow
hook.
Please update to v5.0.1
.