Set Focus in First row of filtered grid

5 posts, 1 answers
  1. Daniel
    Daniel avatar
    4 posts
    Member since:
    May 2017

    Posted 03 Jul 2017 Link to this post

    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.

     

  2. Daniel
    Daniel avatar
    4 posts
    Member since:
    May 2017

    Posted 03 Jul 2017 in reply to Daniel Link to this post

    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.

     

  3. Answer
    Dimitar
    Admin
    Dimitar avatar
    2831 posts

    Posted 03 Jul 2017 Link to this post

    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.
  4. Daniel
    Daniel avatar
    4 posts
    Member since:
    May 2017

    Posted 03 Jul 2017 in reply to Dimitar Link to this post

    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. 

  5. Dimitar
    Admin
    Dimitar avatar
    2831 posts

    Posted 04 Jul 2017 Link to this post

    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.
Back to Top