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

Set Focus in First row of filtered grid

4 Answers 866 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 2
Daniel asked on 03 Jul 2017, 05:06 AM

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

Sort by
0
Daniel
Top achievements
Rank 2
answered on 03 Jul 2017, 08:41 AM

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.

 

0
Accepted
Dimitar
Telerik team
answered on 03 Jul 2017, 10:50 AM
Hi Daniel,

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
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.
0
Daniel
Top achievements
Rank 2
answered on 04 Jul 2017, 12:29 AM

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. 

0
Dimitar
Telerik team
answered on 04 Jul 2017, 05:51 AM
Hello Daniel,

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
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.
Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Answers by
Daniel
Top achievements
Rank 2
Dimitar
Telerik team
Share this question
or