Duplicated
Last Updated: 29 Apr 2021 14:54 by ADMIN
Steven
Created on: 05 Mar 2021 16:24
Category: Grid
Type: Bug Report
0
Since GridCommandEventArgs Field and Value properties are now deprecated, how can I find out which specific field and value I'm updating when using InCell edit mode?

This isn't a bug per say, but with the latest Telerik Blazor update, the GridCommandEventArgs Field and Value properties are now deprecated.  When updating a specific cell in a grid using InCell edit mode, how am I able to know which specific field and value are updated when the OnUpdate event gets called?  Before the latest update, I had the following code:

 

protected override void OnGridRowUpdate(GridCommandEventArgs args)
        {
            validationMessage = ValidateField(args.Field, args.Value);

        }

I realize I have the updated values using args.Item, but I don't want to have to validate the entire row every time I update a cell.  Is there still a way to know what cell I updated, or is that information no more?

Thank you,

Steve

Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
1 comment
ADMIN
Marin Bratanov
Posted on: 05 Mar 2021 16:33

Hi Steve,

With 2.22.0 the OnUpdate event can fire for the entire row if the user edits through the keyboard only, which is why the Field field cannot work anymore.

If the databser itself cannot make comparisons for the old vs new properties, you could consider on of these options:

  • implementing the INotifyPropertyChanged Interface in your model to know which field changes and when
    • You could let the service do a comparison (e.g., loop the fields of the model with reflection, compare the field values between the original item from the Data collection and the one coming in from OnUpdate).
    • Another option would be to store a reference to the copy we provide in OnEdit and hook to its PropertyChanged event (assuming the model implements the interface). Then in OnUpdate unhook the event handler and use the data you've stored through it.
  • using the editor template of each cell (or each important cell) to get more events and control on what happens. Note that this can, cause loss of functionality since the grid can no longer fully control closing the editors (more in the last bullet here).

I would generally recommend you consider simply using the OnUpdate event and passing the entire model to the data service to perform the updates there. If you are looking for excel-like behavior, the 2.22.0 version provides much closer UX to Excel in terms of editing (especially fast, efficient editing with the keyboard) and thus you will actually get fewer calls to OnUpdate than before, so I don't think performance would be an issue.

Our next release will also have data annotation validation for inline and incell editing mode which will also improve the quality of the data.

With that said, I must mark this as "declined" since this is not a bug and per se.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.