Set more than one data in cell

Tags: #<Tag:0x00007f8b1d44d388> #<Tag:0x00007f8b1d44d248>

Is there any way to store more than one value in a cell but display only one. The other one should not be displayed. I want to use it like id for each cell.

employeeData[employeeId][dateKey] = row.code
const resultArray = Object.values(employeeData);
hot.loadData(resultArray)

this is how i load data

but if i want to add code as well as id in the same cell, and id should not be displayed in cell. what can i do?

Hi @beccab904

Here we have an example how to implement key-value data: https://jsfiddle.net/handsoncode/4es5f28c/ In this example it’s assigned to a dropdown, but you can still get the idea about the principles.

Please, keep in mind that it’s a custom implementation so it might not work perfectly with all of the plugins.

The render fucntion gets called when hansontable is intialized. But I am not loading the data in the table during initialization but i am loading it later using loadData. So when renderer gets called the below function can’t find id:
const keyValueListRenderer = function(hot, TD, row, col, prop, value, cellProperties) {
const item = cellProperties.source.find(({
_id
}) => _id === value);

if (item) {
value = item.label;
}

Handsontable.renderers.getRenderer(‘autocomplete’).call(hot, hot, TD, row, col, prop, value, cellProperties);
};

Hi @beccab904

This solution is based on predefined data in the table, and unfortunately we don’t have any example of something that would work without pre-loaded data. You can treat this example as a guide while implementing the solution that suits your requirements.

can i use something like meta data to set id for each cell.

Hi @beccab904

Do you mean setting the id without implementing custom editor, renderer and validator only by setCellMeta hook?