Grid cell edit (only one)

2 posts, 0 answers
  1. Kurt Landuyt
    Kurt Landuyt avatar
    9 posts
    Member since:
    Sep 2010

    Posted 22 Oct Link to this post

    Hi all,

    If you have cell edit enabled, the standard behavior is that after cell update the grid goes automatically to other cell (in edit mode). Would it be possible with a quick setting to only update one cell, and then continue in read only view.

    I have users that update a cell and other cell is automatically set in update mode (not requested by the user).

    Thanks in advance!

    Best regards,

    Kurt

  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    253 posts

    Posted 25 Oct Link to this post

    Hello Kurt,

    You can achieve what you are going for by defining a custom Keyboard Command Provider. You can simply skip the BeginEdit command on the enter key. Here is what I have in mind:
    public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider
       {
           private GridViewDataControl parentGrid;
     
           public CustomKeyboardCommandProvider(GridViewDataControl grid)
            : base(grid)
           {
               this.parentGrid = grid;
           }
     
           public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
           {
               List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
     
               if (key == Key.Enter)
               {
                   commandsToExecute.Clear();
                   commandsToExecute.Add(RadGridViewCommands.CommitEdit);
                   commandsToExecute.Add(RadGridViewCommands.MoveNext);
               }
     
               return commandsToExecute;
           }
       }

    Of course, you will need to set the command provider on the RadGridView instance like so: ("gridView" is the RadGridView name)
    this.gridView.KeyboardCommandProvider = new CustomKeyboardCommandProvider(this.gridView);

    Can you give this approach a try and see if it is suitable for your scenario?

    Hope this helps.

    Regards,
    Vladimir Stoyanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top