Grid Keyboard Shortcut

Hello, I would like to select a row in the grid and then perform a keyboard shortcut for exampe "shift J"

and I would like that trigger a handler function, that can access the data from the selected row.


Is this possible in the syncfusion grid?


1 Reply 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team September 14, 2022 03:26 PM UTC

Hi Pavel,


Greetings from Syncfusion support.


Query: “I would like to select a row in the grid and then perform a keyboard shortcut for example "shift J"

and I would like that trigger a handler function, that can access the data from the selected row.”


We have checked your query and we suspect that you need to customize the keyboard event. If so we suggest you to use OnKeyDown event. So that it will trigger for all keyboard click function. Based on that we can perform our custom operation. Kindly check the attached code snippet and sample for your reference.


 

<SfGrid DataSource="@Employees" @ref="Grid" @onkeydown="@KeyDown">

    <GridColumns>

...

    </GridColumns>

</SfGrid>

 

@code{

    public SfGrid<EmployeeData> Grid;

    private async Task KeyDown(KeyboardEventArgs args)

    {

        if (args.AltKey == true && args.Key == "h")

        {

           var a =  Grid.GetSelectedRecordsAsync();

        } 

    }

 

}


Please let us know if you have any concerns.


Regards,

Monisha


Marked as answer
Loader.
Up arrow icon