Custom Cell Meta Data Disappearing

Tags: #<Tag:0x00007efc651d58e0>

My goal is to store the database id in the cell meta data to be used when changes are made.

To start, I add the id in afterLoadData

afterLoadData: function(sourceData) {
for (var i = 0; i < sourceData.length; i++) {
this.setCellMeta(i, 0, ‘id’, sourceData[i].id);
console.log(this.getCellMeta(i, 0));
}
}

Checking the console, the custom id field is listed in the meta data
image

Later in the afterChange, calling getCellMeta does not have the id field that was previously set.

I found this example here: http://jsfiddle.net/handsoncode/uymcettp/
that is very similar to my need

Hi @deffaudioethan

Please check this demo http://jsfiddle.net/k7fcjybh/7/ (yours did not have the afterChange hook).
I add the custom meta to cell A1 and I get the log when I alter that cell.

Hello @aleksandra_budnik

I have changed the fiddle you sent here: http://jsfiddle.net/v4ncsjug/7/

Added the afterLoadData hook to add the custom id to the cell meta

Doing it this way does not let me access the meta later in the afterChange hook

Thank you

Thank you for sharing thr demos, @deffaudioethan. I will test it on my device and send you feedback after the weekend.

Hi @deffaudioethan

It seems that the afterChange for loadData change runs after the afterLoadData so the changes are not set. When I alter the sequence of scripts and wrap the afterLoadData logic in the setTimeout it works as expected. Here is the updated demo http://jsfiddle.net/Lenc6vyx/3/

What I did to achieve desired result was instead of using the afterLoadData hook, used the afterInit hook to assign the custom IDs. Thank you!

Sounds like a great approach. Thank you for the update, @deffaudioethan