This is a migrated thread and some comments may be shown as answers.

Some questions about GridView edit mode

6 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
haochen
Top achievements
Rank 1
haochen asked on 06 Jan 2016, 06:09 AM

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

Sort by
0
haochen
Top achievements
Rank 1
answered on 06 Jan 2016, 07:24 AM

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.

0
haochen
Top achievements
Rank 1
answered on 06 Jan 2016, 07:27 AM

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

0
haochen
Top achievements
Rank 1
answered on 06 Jan 2016, 07:32 AM
Now the EditTrigger more like selected a cell twice to change the edit mode. 
0
Stefan
Telerik team
answered on 08 Jan 2016, 04:06 PM
Hi Haochen,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
haochen
Top achievements
Rank 1
answered on 11 Jan 2016, 03:05 AM

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.

0
Stefan
Telerik team
answered on 13 Jan 2016, 01:30 PM
Hello Haochen,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
haochen
Top achievements
Rank 1
Answers by
haochen
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or