This question is locked. New answers and comments are not allowed.
Hi,
I have a child gridview declared in HierarchyChildTemplate section of the main gridview. When I insert a row in this inner gridview using InsertRow panel and press Enter key the selected row of the parent gridview changes. Is it a bug? How can I prevent parent row changing?
I have implemented a custom KeyboardCommandProvider and assigned it to the parent gridview. Can I provide different commands for my parent and child grids? For instance, if a user edits a cell in the parent row and presses the Enter key I send MoveNext command to the parent grid, and if it a row in the child grid then I would leave it by default (MoveDown)?
Update: I figured it out. As for the first question, in the RowEditEnded event for the inner grid I should check if it is a GridViewNewRow then I set the grid's selected item to the inserted one:
As for my second question, I use the child grid's Loaded event to set my custom keyboard command provider:
I have a child gridview declared in HierarchyChildTemplate section of the main gridview. When I insert a row in this inner gridview using InsertRow panel and press Enter key the selected row of the parent gridview changes. Is it a bug? How can I prevent parent row changing?
I have implemented a custom KeyboardCommandProvider and assigned it to the parent gridview. Can I provide different commands for my parent and child grids? For instance, if a user edits a cell in the parent row and presses the Enter key I send MoveNext command to the parent grid, and if it a row in the child grid then I would leave it by default (MoveDown)?
Update: I figured it out. As for the first question, in the RowEditEnded event for the inner grid I should check if it is a GridViewNewRow then I set the grid's selected item to the inserted one:
void
GridView_RowEditEnded(
object
sender, GridViewRowEditEndedEventArgs e)
{
if
(e.EditAction == GridViewEditAction.Commit)
{
var grid = sender
as
RadGridView;
if
(e.Row
is
GridViewNewRow)
{
grid.SelectedItem = e.Row.Item;
grid.CurrentItem = grid.SelectedItem;
}
}
}
As for my second question, I use the child grid's Loaded event to set my custom keyboard command provider:
void
childGridView_Loaded(
object
sender, System.Windows.RoutedEventArgs e)
{
var grid = sender
as
RadGridView;
grid.KeyboardCommandProvider =
new
CustomKeyboardCommandProvider(grid);
}