Closed sridhargoshika closed 1 month ago
customizing the script by using a method updateTable
should work.
data = [
{ name:'Jorge', id:'3', age:'40',company:{name:'nokia',location:'us'} },
{ name:'Robert', id:'4', age:'48',company:{name:'nokia',location:'us'} },
{ name:'Santos', id:'5', age:'32',company:{name:'nokia',location:'us'} },
];
jspreadsheet(document.getElementById('my-spreadsheet'), {
data:data,
allowInsertColumn: false,
columns: [
{ type:'text', width:50, name:'id', title:'id' },
{ type:'text', width:100, name:'name', title:'name' },
{ type:'text', width:50, name:'age', title:'age' },
{ type:'object', width:100, data:'company.name', title:'company name' },
{ type:'text', width:100, data:'company.location', title:'company location' },
],
updateTable:function(instance, cell, col, row, val, label, cellName) {
if (col == 3) {
//alert(JSON.stringify(val));
cell.innerHTML = val.name;
}
}
});
You can use that, on the Pro version there is a feature call data binding. https://jspreadsheet.com/docs/data
The outer object has properties name, id, age, and company. The company property is another object with properties name and location.
and the result table looks like this:![image](https://github.com/jspreadsheet/ce/assets/33679589/feab6f58-9948-4d44-b192-47bf3f967057)
An example of this issue here: https://jsfiddle.net/sridharnetha/vf0tknxb/2/