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

How to stay in insert mode

2 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Calvin
Top achievements
Rank 2
Calvin asked on 23 Feb 2012, 08:44 PM
Hi, I'd like to keep the GridView in a continuous insert mode when the currently inserted row is valid and the user presses the Enter key.

Scenario:
A new row is being inserted into the GridView and the user presses the Enter key.  The inserted row's data is valid

Observed Behavior:
The GridView commits the edit and focus then is moved to the next focusable control on the GridView's parent user control.

Desired Behavior:
After the row is commited, I'd like the GridView to re-enter insert mode and preselect (set focus to) the first cell.  In this way, a continuous data-entry mode can be provided.

How can I accomplish this?  Thanks!

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 24 Feb 2012, 08:47 AM
Hello Calvin,

You can predefine the default keyboard behavior by creating your own custom keyboard command provider. Please refer to our online documentation and blog posts for a reference.
 

All the best,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Calvin
Top achievements
Rank 2
answered on 27 Feb 2012, 07:19 PM
Thanks Maya, that helped.

Here's what I would like to do:

    if (key== Key.Return) {
        if (_gridView.CurrentCell.IsIn[Insert]Mode && _gridView.CurrentItem[IsValid]) {
            commandsToExecute.Clear();
            commandsToExecute.Add(RadGridViewCommands.CommitEdit);
            commandsToExecute.Add(RadGridViewCommands.MoveFirst);
            commandsToExecute.Add(RadGridViewCommands.BeginInsert);
        }
    }


How can I detect if the current cell is contained in a new row that is being inserted rather than an existing row that is being edited? I.e., how does one discriminate between edit mode and insert mode?  And secondly how can I predetermine if the row is valid before adding the commands?

thanks!

Subsequent post:  It looks like the following works:

if (_gridView.CurrentCell.IsInEditMode
&& (_gridView.CurrentCell.ParentRow.GetType() == typeof(GridViewNewRow))
&& _gridView.CurrentCell.ParentRowValid) { ...


Tags
GridView
Asked by
Calvin
Top achievements
Rank 2
Answers by
Maya
Telerik team
Calvin
Top achievements
Rank 2
Share this question
or