Keyboard Navigation
- 3 minutes to read
With built-in keyboard support, the GridView‘s primary navigation operations (e.g., accessing a grid within a form, moving focus through grid rows, row selection, row expanding/collapsing and paging) can quickly be performed using a keyboard instead of a pointing device. In addition, enabling keyboard support within GridView helps you create web pages that conform to accessibility guidelines.
To enable keyboard navigation, set the grid’s GridViewSettings.KeyboardSupport property to true
. This activates the following grid features.
- Access Key
- The grid control can be accessed (focused) by using a user-defined keyboard shortcut. This shortcut is composed by combining the preset CTRL+SHIFT combination with a single character string specified via the SettingsBase.AccessKey property. For example, setting the access key of a grid control to the “G” string indicates that an end-user can navigate to the grid by pressing CTRL+SHIFT+G.
- Focused Row
- The Focused Row feature is automatically activated, regardless of the feature’s corresponding property setting (GridViewSettings.SettingsBehavior.AllowFocusedRow). Focus can be moved between rows by using the UP and DOWN ARROW keys. The LEFT and RIGHT ARROW keys can also be used to move row focus, but these keys initially try to collapse/expand a row, and move focus only when collapsing/expanding is not possible. If the currently focused row is the first row in a page (not in the entire grid), an attempt to move focus backward (by pressing the UP or LEFT ARROW key) from the first row will move focus to the previous page. Similarly, an attempt to move focus forward (by pressing the DOWN or RIGHT ARROW key) from the last row in a page will move focus to the next page.
- Row Selection
- The SPACE key can be used to mark a focused row as either selected or unselected. This works if the selection can be applied to a row - that is, if the row is not a group or detail row, the ASPxGridViewBehaviorSettings.AllowSelectByRowClick(via GridViewSettings.SettingsBehavior.AllowSelectByRowClick) property is enabled, or the row contains a command button, selection check box, or radio button. Multiple rows can easily be selected by moving row focus with the ARROW keys (UP/DOWN or LEFT/RIGHT) while holding down the SHIFT key.
- Expanding/Collapsing Rows
- The PLUS and MINUS keys can be used to expand and collapse group and detail rows, respectively. In addition, rows can be collapsed and expanded using the LEFT and RIGHT ARROW keys.
- Paging
- The SHIFT+PAGE UP and SHIFT+PAGE DOWN key combinations can be used to go to the previous and next grid page, respectively.
To see the keyboard navigation feature in action, refer to the GridView - Keyboard Support online demo.