Duplicated
Last Updated: 06 Apr 2022 17:57 by Nemo
Steven
Created on: 05 Mar 2021 16:24
Category: Grid
Type: Bug Report
1
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:
7 comments
Nemo
Posted on: 06 Apr 2022 17:57
Great, looking forward to it, thanks Nadezhda!
ADMIN
Nadezhda Tacheva
Posted on: 06 Apr 2022 16:35

Hi Srihari,

I see my colleague, Svetoslav, has provided more details for this issue in your private ticket. The 3.2.0 release which will contain the fix is expected to be live around mid-April, so you will be able to use the Field and Value properties afterwards.

Regards,
Nadezhda Tacheva
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nemo
Posted on: 30 Mar 2022 21:44

Hi Marin, I raised a ticket for this https://www.telerik.com/account/support-center/view-ticket/1559728 as I get null value for both Field and Value properties of GridCommandEventArgs obj in the OnEdit() event.

I also looked at the workaround for this using the EditField from the grid state, but unfortunately I need the field being edited in the OnEdit event before the user types anything in the editor. My requirement is to initialize the editor with a value when the user clicks on it the first time. And the value will be based on which field the user clicked. Kindly suggest an alternate approach which could work. Thank you.

Marin Bratanov
Posted on: 30 Mar 2022 19:28

There is actually an open issue with them, sorry. You can follow it here https://feedback.telerik.com/blazor/1538887-field-and-value-properties-from-gridcommandeventargs-are-null

 

--Marin

ADMIN
Marin Bratanov
Posted on: 30 Mar 2022 16:47

Hi,

The .Field and .Value fields should be available in the CUD event arguments now: https://docs.telerik.com/blazor-ui/components/grid/editing/overview#basics - they will be populated only for InCell editing. If you have issues with that in the latest version, I recommend opening a support ticket.

 

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nemo
Posted on: 30 Mar 2022 13:11
Hi, imho basic functionality such knowing which field/cell was edited has to be baked into the grid. That would greatly improve the time to build solutions. Frankly, that's the reason we use Telerik. To be able to bring solutions to market quicker. Please consider providing an solution out of the box. Thank you.
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/.