A simple template of dojo's Datagrid is as follows, I am building it for something much more complicated.
For example, how do I update field2's value based on the onChange event of field1 of the same row? Like copy field1's value to field2. The problem is I don't have the id of the particular cell, put onChange under layout or addRow() both doesn't seem right, and seems that onChange: function(){...} can't be used?
/*set up data store*/
var data = {
identifier: "id",
items: []
};
var store = new dojo.data.ItemFileWriteStore({data: data});
/*set up layout*/
var layout = [
defaultCell: {
editable: true,
type: dojox.grid.cells._Widget
}
rows: [
{name: 'ID', field: 'id', width: '30px', widgetClass: dijit.form.TextBox, editable: false},
{name: 'ColA', field: 'field1', width: '100px', widgetClass: dijit.form.TextBox},
{name: 'ColB', field: 'field2', width: '100px', widgetClass: dijit.form.TextBox}
]
];
/*create a new grid*/
var grid = new dojox.grid.DataGrid({
id: 'grid',
store: store,
structure: layout,
singleClickEdit: true,
rowSelector: '15px'});
/*append the new grid to the div*/
grid.placeAt("gridDiv");
/*Call startup() to render the grid*/
grid.startup();
function addRow(){
store.newItem({
id: grid.rowCount,
field1: '-',
field2: '-'});
grid.render();
}
Try using onApplyCellEditin(Value, inRowIndex, inFieldIndex)
instead.