GridView Cancel EndEdit

8 posts, 0 answers
  1. David Clenet
    David Clenet avatar
    3 posts
    Member since:
    Nov 2009

    Posted 26 May 2010 Link to this post

    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.
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 28 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Iosu Buenetxea
    Iosu Buenetxea avatar
    91 posts
    Member since:
    Jan 2008

    Posted 16 Jun 2011 Link to this post

    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.
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Jun 2011 Link to this post

    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
  6. Iosu Buenetxea
    Iosu Buenetxea avatar
    91 posts
    Member since:
    Jan 2008

    Posted 17 Jun 2011 Link to this post

    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.
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Jun 2011 Link to this post

    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
  8. Iosu Buenetxea
    Iosu Buenetxea avatar
    91 posts
    Member since:
    Jan 2008

    Posted 22 Jun 2011 Link to this post

    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.
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Jun 2011 Link to this post

    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
Back to Top
DevCraft banner