JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › onRowUpdate › Reply To: onRowUpdate
January 6, 2022 at 2:26 pm
#102756
admin
Keymaster
Hi Christophe Weibel,
The methods which you used does not refresh the data source. They refresh the HTML Elements used in the grid i.e re-create them, update the layout, etc.
Here is an example which shows how to use the onRowUpdate
window.Smart('#grid', class {
get properties() {
return {
dataSource: new window.Smart.DataAdapter({
dataSource: window.generateData(100),
dataFields: [
'id: number',
'firstName: string',
'lastName: string',
'productName: string',
'available: bool',
'quantity: number',
'price: number',
'total: number'
]
}),
editing: {
enabled: true,
mode: 'row'
},
onRowUpdate(index, row, oldValue, value, confirm) {
if (value.firstName === 'Test') {
confirm(true);
}
else {
confirm(false);
}
},
selection: {
enabled: true,
allowCellSelection: true,
allowRowHeaderSelection: true,
allowColumnHeaderSelection: true,
mode: 'extended'
},
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' }
]
};
}
});
In the above code, when the firstName column’s value is ‘Test’, changes are saved, otherwise they are not.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/