SMART datagrid v.1 > Examples

[ grids ver.1.3.2]   Back  Forward

Dynamic Cell Editor  Example

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. 

Grid - 1
0 rows

In the example above, it specifies the editor for each row in "Flow" column. First, register the editor settings in the grid, 

Code -1
    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. 

Code -2
    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';
    	    }
        }
    },
    ...

View Source JSP 

See Also
DataColumn.editor
LineCellEditor
GridBase.editOptions
Examples
Text Cell Editors
List Cell Editors
Number Cell Editor
Date Cell Editor
Cell Editing