Smart UI Components & Libraries – Grid, Scheduler, Gantt, Kanban for Angular, React, Next.js, Vue, Blazor, JavaScript › Forums › Data Grid › OnCellUpdate (Blazor Server)
- This topic has 2 replies, 2 voices, and was last updated 3 years, 1 month ago by
accsys.
-
AuthorPosts
-
September 18, 2022 at 11:42 am #103695
accsys
ParticipantHi,
My grid currently tracks changes via the OnEndEdit event. This works really well and allows me to update my SQL database with the new value entered. However, this event doesn’t fire if someone copy/pastes a value. Looking at all the events I’m hoping that OnCellUpdate will but am struggling to get the event to work in a Blazor Server app.
The OnEndEdit event passes an Event type which gets converted to an GridEndEditEventDetail type where I can easily access the row, column value etc…
async void EndEditHandler(Event args)
{
GridEndEditEventDetail detail = args[“Detail”] as GridEndEditEventDetail;
long rowId = detail.Row;
string colId = detail.Col
}The OnCellUpdate event passes an Object type and looking at the types available I assumed this would be a GridRowCell object as this seems to have the Value and OldValue properties that the OnCellUpdate supposedly passes. I’ve tried the following…
async void CellUpdateHandler(Object args)
{
GridRowCell detail = args as GridRowCell;
string oldValue = detail.OldValue.ToString();
string newValue = detail.Value.ToString();
}But detail always ends up as a null reference.
I’m fairly new to C# / Blazor Server and very new to your components so I’m sure I’m missing something obvious but I just can’t work out what it is! The Blazor examples are very useful but I feel there needs to be much more of them. For example the OnCellUpdate just has one section in the API documentation but doesn’t really explain how you can use it.
Any help would be appreciated.
Thanks,
Tobie
September 19, 2022 at 1:03 pm #103704svetoslav_borislavov
ParticipantHi,
OnCellUpdate accepts object you cannot cast it to any type.
I suggest you use it as an object.If you have any further questions, please do not hesitate to contact us!
Best Regards,
Svetoslav BorislavovSmart UI Team
https://www.htmlelements.com/September 19, 2022 at 1:50 pm #103706accsys
ParticipantOk thanks.
Would you be able to post an example of how I can access the relevant properties such as OldValue, Value, Row, Column etc.
Many thanks,
Tobie
-
AuthorPosts
- You must be logged in to reply to this topic.