Last Updated: 27 Nov 2019 19:28 by ADMIN
Created on: 27 Nov 2019 10:35
Category: Grid
Type: Bug Report
OnEdit Event not triggered when using the Add command.

When clicking on the Add Button in a Grid, a new item is created and displayed in edit mode.

Problem is, the OnEdit event is not triggered.  I need to set a default value for new items and added the code in the OnEditHandler with if(args.IsNew){ //set default value}.

Unfortunately this does not work because the event is not triggered.  This makes me wonder what "args.IsNew" is for if not for the usecase described above.

Marin Bratanov
Posted on: 27 Nov 2019 19:28

Hello René,

The OnEdit event is for editing existing items only, and the IsNew flag is to determine whether the item was there in the original data source or came from the grid when performing the actual data source operations. Here's the relevant extracts from the documentation:

OnEdit - fires when the user is about to enter edit mode for an existing row. Cancellable.

IsNew - a boolean field indicating whether the item was just added through the grid. Lets you differentiate a data source Create operation from Update operation in the OnClick event of a command button.

For example, an implementation of batch editing can be done like this: I also agree that at this point this is not the most functional setup, and perhaps the IsNew flag may be unnecessary.

At this point, I can't say how default values will be implemented (it may be that OnEdit may start firing for new items, although that would be a breaking change), and for anyone else finding this thread (I see that RenĂ© has found it already), please Vote for and Follow the feature request for that:

With all that said, I have forwarded the case for review by the dev team, even though at this point I must close it because we can't consider it a bug - this is the intended behavior of the events at this stage. Nevertheless, feel free to add comments on how you would expect this to work so we can gather feedback.

Marin Bratanov
Progress Telerik

 UI for Blazor
Posted on: 27 Nov 2019 10:52
As a workaround I'm now setting the default value in EditorTemplate.