Keybinding i SfTreeGrid

Hi,

How can I bind special commands to Ctrl+Alt+Up and Ctrl+Alt+Down and Ctrl+Alt+Left and Ctrl+Alt+Right

I have tried adding keybinding to the Window, however, the SfTreeGrid control overrides and just moves the cursor to the either end of the grid, and not triggering the commands.

Please advise.

Best regards,


3 Replies

MA Mohanram Anbukkarasu Syncfusion Team December 7, 2020 12:52 PM UTC

Hi Johannes, 

Thanks for contacting Syncfusion support.  

Can you please share more details about the requirement to handle Ctrl+Alt+Up and Ctrl+Alt+Down and Ctrl+Alt+Left and Ctrl+Alt+Right keys? Based on the requirement we will check the feasibility in our end and provide prompt solution at earlier.  

Regards, 
Mohanram A. 



MR MrHessellund December 7, 2020 03:03 PM UTC

Hi,

I have implemented commands in the viewmodel to move the selected items up/down in the nested view, as well commands to increase/decrease level. That is what the keybindings are for.

I need to ensure that while navigating the sftreegrid using the keyboard there are keybindings to move the selected items. I already have buttons in place outside the sftreegrid control, but the sftreegrid is consuming the said keys.

Looking forward to your suggestion.

Best regards,


MA Mohanram Anbukkarasu Syncfusion Team December 8, 2020 12:46 PM UTC

Hi Johannes, 

Thanks for the update.  

You can handle the key operations in the SfTreeGrid by creating custom selection controller and override the ProcessKeyDown method instead of using KeyBinding  as shown in the following code example.  

Code example :  

this.treeGrid.SelectionController = new TreeGridSelectionControllerExt(this.treeGrid); 

public class TreeGridSelectionControllerExt : TreeGridRowSelectionController 
{ 
    public TreeGridSelectionControllerExt(SfTreeGrid treeGrid) 
        : base(treeGrid) 
    { 
    } 
 
    protected override void ProcessKeyDown(KeyEventArgs args) 
    { 
        if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) && 
                    (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) && Keyboard.IsKeyDown(Key.Up)) 
        { 
            // Do the customization need for Ctrl+Alt+Up key here 
        } 
 
        base.ProcessKeyDown(args); 
    } 
} 


Please let know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon