Tab index for cell on gridview

4 posts, 0 answers
  1. Bao
    Bao avatar
    43 posts
    Member since:
    Jan 2015

    Posted 25 Sep Link to this post

    hi,

    I am working with gridview now. I have one columncheckbox on the gridview, and on the header i have checkbox to select all. i want when i tab into gridview the checkbox all will be focus for user can select all without mouse.

    https://www.screencast.com/t/bLgGMCd50q

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 26 Sep Link to this post

    Hello Bao,

    The header cell cannot be focused or set as current. What you can do is to set the current row to null when the grid gains the focus. Then you can use the KeyDonwn event to check/uncheck the cells:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        var col = radGridView1.Columns["bool"] as GridViewCheckBoxColumn;
        col.EnableHeaderCheckBox = true;
        radGridView1.GotFocus += RadGridView1_GotFocus;
        radGridView1.KeyDown += RadGridView1_KeyDown;
    }
     
    private void RadGridView1_KeyDown(object sender, KeyEventArgs e)
    {
        if (radGridView1.CurrentRow == null && e.KeyCode == Keys.Space)
        {
            var col = radGridView1.Columns["bool"] as GridViewCheckBoxColumn;
            col.Checked = col.Checked == Telerik.WinControls.Enumerations.ToggleState.On ?  Telerik.WinControls.Enumerations.ToggleState.Off: Telerik.WinControls.Enumerations.ToggleState.On;
             
        }
    }
     
    private void RadGridView1_GotFocus(object sender, EventArgs e)
    {
        radGridView1.CurrentRow = null;
    }

    I hope this will be useful.

    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.
  3. Bao
    Bao avatar
    43 posts
    Member since:
    Jan 2015

    Posted 26 Sep in reply to Dimitar Link to this post

    HI,

    With your code, it is not working. The checkbox does not change anything.

  4. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 27 Sep Link to this post

    Hi Bao,

    What version of the suite are you using? I have tested this with the latest version and it is working on my side (see attached video). 

    I am looking forward to your reply.

    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