JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › onCellUpdate
- This topic has 4 replies, 2 voices, and was last updated 2 years, 10 months ago by admin.
-
AuthorPosts
-
January 17, 2020 at 10:55 pm #100579adminKeymaster
<div class=”bbp-reply-content”>
hi,
can you help me use onCellUpdate with grid? where can I to find the example?
Fabio
</div>January 19, 2020 at 9:33 am #100583adminKeymasterHi 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,
PeterJanuary 23, 2020 at 9:12 am #100584adminKeymasterThank you very much
December 31, 2021 at 6:19 pm #102720JamesParticipantHi,
Please where do I find a similar implementation in Angular?
January 2, 2022 at 9:48 am #102728adminKeymasterHi James,
onCellUpdate is a property so in angular in app.component.ts it would be:
` onCellUpdate = function(cell, oldValue, newValue, confirm) {
oldValue = cell.value;
alert(cell.row.id + “/” + cell.column.dataField);
if (newValue === “test”) {
confirm(false);
}
else {
confirm(true);
}
}`in the template, you will need to set the onCellUpdate grid property to point to the property in the app.component.ts.
Best regards,
Peter StoevSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.