1.9 KiB
title | description | type | page_title | slug | tags | res_type | category |
---|---|---|---|---|---|---|---|
Select Native Grid Rows When Specific Buttons are Pressed. | An example demonstrating how the rows' selection inside the Native Grid component can be controlled and based on specific keyboard keys. | how-to | Select Grid rows when Shift, Ctrl or Command(for Mac) buttons are pressed | Kendo UI for Vue Native Grid | grid-select-row-when-shift-ctrl-command-are-pressed | grid, selection, specific key, shift, ctrl, command, key, press, kendovue, native | kb | knowledge-base |
Environment
Product Version | 3.10.0 |
Product | Progress® Kendo UI for Vue Native |
Description
This KB article demonstrates how you can limit the rows' selection of the Native Grid by pressing specific keyboard keys. In the following example the rows of the Native Grid can be selected or deselected only when the Shift, Ctrl or Command(for Mac) keyboard buttons are pressed.
KB sections
Solution description
To achieve the following scenario, we use the [onRowClick]({% slug api_grid_gridprops %}#toc-onrowclick) event of the Native Grid and the following code:
onRowClick(event) {
if (event.event.metaKey || event.event.ctrlKey || event.event.shiftKey) {
event.dataItem[this.selectedField] =
!event.dataItem[this.selectedField];
}
}
Runnable example
To test the following example press Ctrl
, Shift
or Command(for Mac)
buttons and click on selected Grid row.
{% meta id:index height:600 %} {% embed_file grid-select-row-when-shift-ctrl-command-are-pressed/main.vue preview %} {% embed_file grid-select-row-when-shift-ctrl-command-are-pressed/main.js %} {% endmeta %}