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

Row edit API methods not working

2 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sprucely
Top achievements
Rank 1
sprucely asked on 02 May 2011, 07:50 PM
I can initiate the insertion of a new row by pressing [insert] or clicking on the "Click here to add..." row, but RadGridView.BeginInsert() does nothing. Likewise, I can cancel the addition of a new row by pressing [esc] twice (once for the cell and once for the row), but RadGridView.CancelEdit() does nothing. CancelEdit() also does nothing for a non-new row in edit mode.

Am I missing something? I have tried just about everything short of simulating the keystrokes, which I will try if I can't find a solution that is less of a hack.

2 Answers, 1 is accepted

Sort by
0
sprucely
Top achievements
Rank 1
answered on 02 May 2011, 10:00 PM
Correction: CancelEdit() does work for non-new row in edit mode.

But that still leaves me with how to handle the new row. I have tried two hacks with no luck...
sending key event...
var keyEventArgs = new KeyEventArgs(Keyboard.PrimaryDevice,
    Keyboard.PrimaryDevice.ActiveSource,
    0, Key.Insert) { RoutedEvent = Keyboard.KeyDownEvent };
this.DataGridControl.RaiseEvent(keyEventArgs);

calling command directly...
var routedCommand = RadGridViewCommands.BeginInsert as RoutedCommand;
if (routedCommand != null)
    routedCommand.Execute(null, this.DataGridControl);

0
sprucely
Top achievements
Rank 1
answered on 03 May 2011, 07:31 PM
My bad. The methods are working after all. The problem was that I had inadvertently bound a second RadGridView to my view model and was calling the methods on the non-visible one.
Tags
GridView
Asked by
sprucely
Top achievements
Rank 1
Answers by
sprucely
Top achievements
Rank 1
Share this question
or