Hi,
I have some question about GridView edit mode.
Question 1:
In the GridView's PerpareCellForEdit event, I have some business code for verifying whether the current cell can be edited. If business cannot let the cell be edited, I used CancelEdit() function to exit edit mode, but the CancelEdit() function will fire CellEditEnded event. I have some code for DB communication in that event. Do you have some way the can leave edit mode but don't fire CellEditEnded event?
Question 2:
When we double clicked a cell, it will change to edit mode. If we click the other cells or other places, it will leaves edit mode, but if we click the next cell in the same row, the next cell will still in the edit mode and fired CellEditEnded event and PrepareCellForEdit event. I don't want to click the next cell in the same row stay with in edit mode, I want to leave edit mode when click the next cell. Is there a way to achieve it?
Than you
6 Answers, 1 is accepted
I find a way to resolved question 1.
I changed PrepareCellForEdit event to BeginningEdit event, and set the e.Cancel = true.
But in the PrepareCellForEdit event I try to set e.Cancel = true, is not working.
I have a new additional question:
I want to change the EditTrigger to double click, not click current selected cells. Is there have a way to do this?
Thank you
Thank you for the detailed information.
However, I would like to suggest you a slightly different approach for this scenario. Instead of using the editing events of RadGridView, I suggest you benefiting from the validation functionality that the control supports, as it is triggered before the editing one. I suggest you taking a look at the Validating section of RadGridView's online help. Shortly said, if the validation logic for determining whether a cell can be edited does not pass, the editing events would not be fired and the control will leave edit mode.
As for the editing operation in general, you can take a look at the Updating an Entry help topic.
Hope this helps.
Best Regards,
Stefan X1
Telerik
Hi Stefan,
Thank you for you reply.
The validating function is awesome! I know how to do it.
I read the “Updating an Entry” help. this document says F2 or double click can trigger edit mode. but I set EditTriggers = F2, the double click cannot change cell to edit mode. If I don't set EditTriggerts or set EditTriggers = Default, When I click the cell twice very slowly, it still will change cell to edit mode.
You should be able to achieve this requirement by setting the EditTriggers property of the control to "None". Then you should subscribe to the MouseDoubleClick event of RadTreeListView and call the BeginEdit() method. You can take a look at the code snippet below.
private
void
radTreeListView_MouseDoubleClick(
object
sender,
MouseButtonEventArgs e)
{
this
.radTreeListView.BeginEdit();
}
Can you please clarify whether this is the behavior of RadTreeListView you were trying to achieve?
All the best,
Stefan X1
Telerik