Hi,
How can i set focus or select the first row always of filtered grid? I already used gvGenericBrands.Rows[0].IsSelected = true;
gvGenericBrands.Rows[0].IsCurrent = true; .
Please see attached image. Thanks in advance.
4 Answers, 1 is accepted
Hi,
I already solved this issue using MasterView properties of RadGridView.
I encounter another problem when I select the grid and select the first row programatically, the Up and Down button does not work. Its stack in the first row.
gvItemSelection.Select();
gvItemSelection.Rows[0].IsSelected = true;
gvItemSelection.Rows[0].IsCurrent = true;
Thanks in advance.
You should use the ChildRows collection for this:
private
void
RadGridView1_FilterChanged(
object
sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
radGridView1.CurrentRow = radGridView1.ChildRows[0];
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Hi Dimitar,
Thank you very much for this. I have another question. How to make arrow down key to put the cell in edit mode? same behavior when you press space or click the cell.
Thanks again in advance.
To achieve this you need to create a custom row behavior which allows you to override the methods that are handling the keys. For example:
public
class
CustomGridDataRowBehavior : GridDataRowBehavior
{
protected
override
bool
ProcessDownKey(KeyEventArgs keys)
{
if
(!
this
.GridControl.IsInEditMode)
{
this
.GridControl.BeginEdit();
}
return
true
;
}
}
You can change the default behavior with the following code:
BaseGridBehavior gridBehavior = radGridView1.GridBehavior
as
BaseGridBehavior;
gridBehavior.UnregisterBehavior(
typeof
(GridViewDataRowInfo));
gridBehavior.RegisterBehavior(
typeof
(GridViewDataRowInfo),
new
CustomGridDataRowBehavior());
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik