Custom Tab index on Column in dataGrid.

Hi,

I need to implement the TabIndex to the Columns.
Now the TAB key moves to the next cell, but i need to move to the "next index Columns", like a tab index in control forms.
I don'f find this property to the GridColumn, there is any solution?
I try to catch the key down event and set focus programmatic, i disabled the TAB key pressed and now i search in a dictionary for the index order, but i don't like this solution.


Thank you.

1 Reply

JG Jai Ganesh S Syncfusion Team November 9, 2017 04:38 PM UTC

Hi Marco, 
 
We regret to inform you that we don’t have a direct property for moving in GridColumn using TAB key. However, you can achieve this by in sample level by override the ProcessKeyDown in customized SelectionController. 
 
Code Snippet: 
this.SfdataGrid.SelectionController = new CustomSelectionController(this.SfdataGrid); 
 
public class CustomSelectionController : GridSelectionController 
    { 
        public CustomSelectionController(SfDataGrid dataGrid) 
            : base(dataGrid) 
        { 
        } 
 
        protected override void ProcessKeyDown(KeyEventArgs args) 
        { 
            // Get the CurrentCell column index 
            var currentColumnIndex = this.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex; 
             
            base.ProcessKeyDown(args); 
            
            bool isAddNewRow = DataGrid.IsAddNewIndex(CurrentCellManager.CurrentRowColumnIndex.RowIndex); 
            if (SelectionHelper.CheckShiftKeyPressed()) 
                return; 
            if (args.Key == Key.Tab) 
            { 
                var rowIndex = this.CurrentCellManager.CurrentRowColumnIndex.RowIndex; 
                var firstFocusedColumnIndex = GetFirstFocusedColumnIndex(); 
                var columnIndex = GetNextFocusedColumnIndex(currentColumnIndex); 
                 
                this.MoveCurrentCell(new RowColumnIndex(rowIndex,columnIndex +1)); 
                this.DataGrid.ScrollInView(this.CurrentCellManager.CurrentRowColumnIndex); 
            } 
             
        } 
    } 
 
 
 
 
In the above sample, we have customized the TAB key behavior by moving after one index in SfDataGrid. Bu referring the above code you can customize your own behavior of the TAB key using ProcessKeyDown method. 
 
Regards, 
Jai Ganesh S

Loader.
Up arrow icon