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

GridView Cancel EndEdit

7 Answers 234 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Clenet
Top achievements
Rank 1
David Clenet asked on 26 May 2010, 02:06 PM
Hello,
I would like to implement row editing functionalities to my griView, but throw a special way.
In fact i want to begin edit, and end edit only by buttons that i implements in a column.
I have no problem to enter into edit mode for the row, but i want to leave this mode only by cliking on another button, and never by changing row.

Is it possible to leave the edit mode only when i ask for it ?

Thanks
David C.

7 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 28 May 2010, 08:07 AM
Hi David Clenet,

I am afraid this is not entirely supported by RadGridView. However you may try some hacks - You may prevent the cell from  exiting edit mode by subscribing to the validating events ( CellValidating) and set e.e.IsValid = false within the event handler. I am not sure this will do the trick but this is the only way to prevent the cell to exit edit mode.

Kind regards,
Pavel Pavlov
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Iosu Buenetxea
Top achievements
Rank 1
answered on 16 Jun 2011, 05:21 PM
Hi. I do also want to allow editing and accepting/cancelling editing using only buttons.  I achieved the first thing easily using the EditTriggers property set to None.  But I have not found a way for the latter.   Is it possible? 

Regards,


Iosu.
0
Milan
Telerik team
answered on 17 Jun 2011, 07:49 AM
Hello Iosu Buenetxea,

You are on the right track. RadGridView exposes a command called CommitEdit which will commit the pending edit. Please take a look at this help topic for more information.


Kind regards,
Milan
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Iosu Buenetxea
Top achievements
Rank 1
answered on 17 Jun 2011, 09:09 AM
Hi, Milan.

Indeed, I use those commands, but I am not able to accept/cancel editing only using buttons.  When the user selects another row, the editing is committed in the editing row.  The user should not be able to exit the editing row until he/she uses the commit/cancel button.  Can you show me a working example which shows how to achieve what I want?

Iosu.
0
Dimitrina
Telerik team
answered on 21 Jun 2011, 02:11 PM
Hi Iosu Buenetxea,

 You may subscribe to the RowValidating event of the RadGridView. Inside it you may set the row to be not valid until one of the accept/cancel editing buttons has been clicked.

private void clubsGrid_RowValidating(object sender, GridViewRowValidatingEventArgs e)
       {
           if (!commandCalled)
           {
               e.IsValid = false;
               GridViewCellValidationResult result = new GridViewCellValidationResult();
               result.ErrorMessage = "Please use the commit/cancel editing buttons!";
               e.ValidationResults.Add(result);
           }
           else
           {
               commandCalled = false;
           }
       }

You may use a global variable (commandCalled) to save the state of the command buttons "click". When you do the validation you should reset the value if the global variable.

I have prepared a sample project where you may see how it is working. Of course you still need to secure that this custom changed functionality is working fine at all cases.

Greetings,
Didie
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Iosu Buenetxea
Top achievements
Rank 1
answered on 22 Jun 2011, 03:25 PM
Thanks for the example, Didie.  But, I don't think it will be appropriate to mix entity validation messages with a user action denial.

Is there a solution without using validation messages?  

Regards,

Iosu.
0
Dimitrina
Telerik team
answered on 27 Jun 2011, 10:24 AM
Hi Iosu Buenetxea,

 Do you mean only the Validation messages in your statement "mix entity validation messages with a user action denial"?

If you do mean that you prefer not to use the validation messages to inform the user that this action is not allowed, then you may use a simple popup message box (or any other user notification), like:

private void clubsGrid_RowValidating(object sender, GridViewRowValidatingEventArgs e)
       {
           if (!commandCalled)
           {
               e.IsValid = false;
               // Optional
               MessageBox.Show("Please use the commit/cancel editing buttons!");
           }
           else
           {
               commandCalled = false;
           }
       }
 
       private void clubsGrid_RowValidated(object sender, GridViewRowValidatedEventArgs e)
       {
           if (e.Row.IsValid)
           {
               commandCalled = false;
           }
       }

If you do mean that the approach with the row validation is not appropriate, then unfortunately we cannot suggest you a better one with the current realization of the RadGridView.

If there is some misunderstanding, may you please share with us where is it?  Greetings,
Didie
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
David Clenet
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Iosu Buenetxea
Top achievements
Rank 1
Milan
Telerik team
Dimitrina
Telerik team
Share this question
or