How add data attr to cell?

Tags: #<Tag:0x00007efc72ee5f78>

I want to put in an id data-attr to know which cell belongs to each cell in the table. I tried custom-rendering but I failed.
How do I add a data attr to a cell?

Edit: I solved setCellMeta & getCellMeta but getCellMeta function not return meta in afterChange hook.

                hot.setCellMeta(i,ii,\'id\',res[pc].id);

                hot.updateSettings({  
                    afterChange: function (change, source) {
                        if (source === \'loadData\') {
                          return;
                        }   
                        var test = this.getCellMeta(change[0],change[1]);
                        console.log(test);  
                    }
                  });

Console log:

Return log i tried out afterChange;

Help me please :frowning:

Firstly, I am not a Hot employee. But while you await a definitive response from Hot support:

Edit: I solved setCellMeta & getCellMeta but getCellMeta function not return meta in afterChange hook.

Why do you expect afterChange to fire in response to setCellMeta()? afterChange is for data change. Don’t you want https://docs.handsontable.com/pro/1.15.0/Hooks.html#event:afterSetCellMeta ?

Thanks for reply. I not usage afterSetCellMeta because load data with ajax and set cell meta “id” info, i want to get cell meta on fire afterChange. I use “id” meta info on update cell data with ajax and php.

Hi @wdrleo

I am not sure if I understand the case. Here is an example where I define a custom metadata via setCellMeta and call it via getCellMeta in the afterChange http://jsfiddle.net/doezzk9e/

Please let me know what I am missing in this example to meet your requirements.