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

Tab index for cell on gridview

3 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bao
Top achievements
Rank 1
Bao asked on 26 Sep 2017, 01:55 AM

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

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 26 Sep 2017, 08:38 AM
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.
0
Bao
Top achievements
Rank 1
answered on 26 Sep 2017, 07:42 PM

HI,

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

0
Dimitar
Telerik team
answered on 27 Sep 2017, 10:18 AM
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.
Tags
GridView
Asked by
Bao
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Bao
Top achievements
Rank 1
Share this question
or