We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using keyboard in grid

We are trying to use the keyboard in a datagrid

specifically we want the user to be able to use a key to 

1) mark a row with specific data

2) go to the next row

in order to do this we added an onkey_up event as follows


        var pressedKey = args.Key;
        int i = 0;
        if (pressedKey==" ")
        {
            var selectedRows = await this.iboGrid.GetSelectedRecordsAsync();

            if (selectedRows.Count() == 0 || selectedRows.Count() > 1)
            {
                selectedOffer = null;
            }
            else
            {
                selectedOffer = selectedRows.FirstOrDefault();
                selectedOffer.isSelected = true; // mark row data
                var idx = await iboGrid.GetRowIndexByPrimaryKeyAsync(selectedOffer.id);
                await iboGrid.SelectRowAsync(idx + 1);
            }
        }

This seems to work. the row gets modified and the selection moves to the next row but when hitting the space bar again the selection moves back to the previous row and then jumps to the n


3 Replies

MS Michael Salzlechner November 9, 2022 02:07 PM

the same code executed from a button works perfectly so there must be something that does not allow this to function within a keyboard event i guess



MS Michael Salzlechner November 9, 2022 06:11 PM

looks like the issue is limited to the space key. When using other keys like '1' or '2' etc it works




SP Sarveswaran Palani Syncfusion Team November 14, 2022 10:43 PM

Hi Michael,


We suspect that you faced issue on using spacebar key. Defaultly, we gave keyboard navigation support for doing some actions. So, predefined keys invokes some actions. Kindly refer the attached documentation and demo for your reference. And also, share the requirement or details of an issue while using spacebar key, It’ll will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.

Documentation: https://blazor.syncfusion.com/documentation/datagrid/accessibility#keyboard-navigation


Demo: https://blazor.syncfusion.com/demos/datagrid/keyboard-navigation?theme=fluent


Regards,

Sarveswaran PK


Loader.
Live Chat Icon For mobile
Up arrow icon