RadDataGrid CommitEdit command does not show modifed value for cell

1 Answer 61 Views
DataGrid
Stephen
Top achievements
Rank 1
Iron
Iron
Stephen asked on 25 Jul 2023, 12:11 AM

This is mainly a question for me as it wasted about an hour of my time today...

I have a datagrid where I have attached two commands: BeginEdit and CommitEdit.

I have set breakpoints in each of these command classes and the BeginEdit breakpoint always gets hit, but the CommitEdit will only break if you select another cell or row in the datagrid and NOT when the datagrid loses focus. It appears that something is doing a commit as when I look at the data after I have edited and left the datagrid form, the change was made to the viewmodel that the datagrid row was displaying.

As I stated, I wasted too much time trying to figure out how to perform an edit in my datagrid, but your documentation says NOTHING about there being some catchall trap that performs the commit. Either this is a bug - the CommitEdit command IS NOT executed when the cell loses focus or your documentation needs to be updated...

It took waaaaaaaaaaaaaaaaay toooooooooooo long to figure this out...

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 25 Jul 2023, 07:13 AM

Hi Stephen,

This is how the editing works in the Grid. In general you have to tap on different cell to exit edit mode of the DataGrid. We have a Editing Commands example here: https://github.com/telerik/maui-samples/tree/main/Samples/SdkBrowser/Examples/DataGridControl/CommandsCategory/EditingExample The example uses begin edit and commit edit commands.

For WinUI, there is a keyboard navigation support, so when you pressing the Enter key -> Selects the next or previous row. When in edit mode, the changes are committed and the next row is selected. The keyboard keys are described here: https://docs.telerik.com/devtools/maui/controls/datagrid/keyboard-support 

Regards,
Didi
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.

Stephen
Top achievements
Rank 1
Iron
Iron
commented on 25 Jul 2023, 12:59 PM | edited

Hi Bibi,

Thank you for your response!

I think you missed my point. I did follow that exact example when I started to configure editing on this particular datagrid. This is what I expected:

  • When a cell is placed into edit mode the BeginEdit command is executed, the correspond cell should be in edit mode. This works as expected.
  • When a user clicks in another cell, the edited cell loses focus and the CommitEdit command is executed. This works as expected.
  • When a user clicks OUTSIDE of the entire datagrid, the datagrid loses focus. At that point, I contend that your datagrid code examine if there are any cells that are in edit mode, and if any are found, their pending CommitEdit command execution SHOULD BE fired if it is defined. Or, at a minimum, the CancelEdit should be executed, if defined. This ensures your process is symmetrical (there is a start/finish pair) and consistent. What I observed was a cell that was in edit mode and when the datagrid (and cell) loses focus the CommitEdit did NOT execute. I contend this is a bug. I assert that there should always be a BeginEdit /CommitEdit pair that get executed or a at a minimum a BeginEdit/CancelEdit pair that gets executed. The cell is open and it should ALWAYS closed through these commands if they are defined when focus is lost.

Does that make sense?

Steve

Didi
Telerik team
commented on 28 Jul 2023, 10:39 AM

Hi Stephen,

Thank you for the described points.

Regarding to the third point -> when clicking outside of the grid nothing happens, no command is executed- > this is expected. In WinUI the DataGrid does not commit the current edit operation when the editor looses focus/tap outside of the grid because this causes exceptions during keyboard navigation. On WinUI there is a keyboard navigation implemented. 

On Android you need to tap on another cell to exit edit mode.

Stephen
Top achievements
Rank 1
Iron
Iron
commented on 28 Jul 2023, 09:37 PM

Hi Bibi,

"Regarding to the third point -> when clicking outside of the grid nothing happens, no command is executed- > this is expected." I agree with this much of what you state above.

Your description for when the datagrid/cell loses focus is not what I observed, though. What I did see was the cell properly went into edit mode (the BeginEdit command was invoked). So far, so good. Then I made the edit and clicked outside of the datagrid forcing it to lose focus. When I examined the view model that was being used as the binding context for the row the property WAS changed! The CommitEdit command was NOT executed and that is what confused me. So, how did the property get updated if it wasn't committed? It seems as though the CommitEdit command doesn't need to be executed based on what I have observed...

Eagerly awaiting your response!!

Steve

Didi
Telerik team
commented on 03 Aug 2023, 10:17 AM

Hi Stephen,

I cannot reproduce the described behavior. Send me a sample project and a video with exact steps you follow

Tags
DataGrid
Asked by
Stephen
Top achievements
Rank 1
Iron
Iron
Answers by
Didi
Telerik team
Share this question
or