How add data attr to cell?

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?

https://image.prntscr.com/image/a5XWv1tsQgmMzvMb4RjuUA.png

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:

https://image.prntscr.com/image/lYV0Fg4QRniVxJDtLWm-bQ.png

Return log i tried out afterChange;

https://image.prntscr.com/image/HyjqP5GAQ_SCOVmLTfqoNA.png

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 Hooks API reference - JavaScript Data Grid | Handsontable ?

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.