#100583
admin
Keymaster

Hi Fabio,
Please, refer below to a sample implementation of the onCellUpdate callback function. It provides information about old and new cell value, the cell that is edited and also a confirm callback function which you may use to cancel the changes. In the example, when “test” is entered, the value is not saved, otherwise it is saved after editing.

Smart('#grid', class {
get properties() {
return {
onCellUpdate: function(cell, oldValue, newValue, confirm) {
oldValue = cell.value;
alert(cell.row.id + "/" + cell.column.dataField);
if (newValue === "test") {
confirm(false);
}
else {
confirm(true);
}
},
dataSource: new Smart.DataAdapter(
{
dataSource: generateData(1000),
dataFields:
[
'id: number',
'firstName: string',
'lastName: string',
'productName: string',
'available: bool',
'quantity: number',
'price: number',
'total: number'
]
}),
editing: {
enabled: true,
mode: 'cell'
},
columns: [
{
label: 'First Name', dataField: 'firstName'
},
{ label: 'Last Name', dataField: 'lastName' },
{ label: 'Product', dataField: 'productName' },
{ label: 'Available', dataField: 'available', template: 'checkBox', editor: 'checkBox' },
{ label: 'Quantity', dataField: 'quantity', editor: 'numberInput' },
{ label: 'Unit Price', dataField: 'price', editor: 'numberInput', cellsFormat: 'c2' }
]
}
}
});

Hope this helps.
Regards,
Peter