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

How to move focus to next row on commit?

I have a sfDataGrid and it has one editable column. How can I move focus to the next row on commit the previous row?

1 Reply

AN Ashok N Syncfusion Team August 3, 2017 07:44 PM UTC

  
Hi Gangatharan, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve your requirement by handling CurrentCellBeginEdit event and set the SelectedIndex based on the current edited row. Please refer the below code example  
 
public partial class SfDataGridPage : ContentPage 
{ 
    int currentRowIndex = -1; 
    public SfDataGridPage() 
    { 
        InitializeComponent(); 
        dataGrid.CurrentCellBeginEdit += DataGrid_CurrentCellBeginEdit; 
    } 
    private async void DataGrid_CurrentCellBeginEdit(object sender, GridCurrentCellBeginEditEventArgs args) 
    { 
        await Task.Delay(100); 
 
        var row = dataGrid.GetRowGenerator().Items.FirstOrDefault(x => x.RowIndex == args.RowColumnIndex.RowIndex); 
        currentRowIndex = args.RowColumnIndex.RowIndex; 
        var column = (row.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "VisibleColumns").GetValue(row) as List<DataColumnBase>).FirstOrDefault(x => x.ColumnIndex == args.RowColumnIndex.ColumnIndex); 
 
        if (((column as IElement).Element as ContentView).Content is Entry) 
        { 
            (((column as IElement).Element as ContentView).Content as Entry).Completed += Entry_Completed; 
        } 
    } 
    private async void Entry_Completed(object sender, EventArgs e) 
    { 
        dataGrid.EndEdit(); 
        await Task.Delay(500); 
        this.dataGrid.SelectedIndex = currentRowIndex + 1; 
    } 
} 
 
 
 
Regards, 
Ashok 


Loader.
Up arrow icon