Data cell editor is specified through DataColumn.editor property and applied to all cells contained in the corresponding column. Sometimes, however, the data cell contained in the same column may need to provide different editors for each row, and GridBase.registerCellEditors and DataColumn.editorCallback can be used in this case.
In the example above, it specifies the editor for each row in "Flow" column. First, register the editor settings in the grid,
grid.registerCellEditors([{
id: "text01"
}, {
id: "list01",
type: "list",
values: ["import", "export"]
}, {
id: "list02",
type: "list",
values: ["import", "export"],
labels: ["수입", "수출"]
}]);
and then specify callback function in editorCallback when set the column.
var columns = [{
name: "Flow",
editorCallback: function (index) {
var v = grid.getValueAt(index.rowIndex, 'trade');
if (v > 20000) {
return 'list02';
} else if (v > 10000) {
return 'list01';
} else {
return 'text01';
}
}
},
...