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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to move focus to next row on commit?

Thread ID:

Created:

Updated:

Platform:

Replies:

131896 Aug 2,2017 04:23 AM UTC Aug 3,2017 07:44 PM UTC Xamarin.Forms 1
loading
Tags: SfDataGrid
Gangatharan Baskaran
Asked On August 2, 2017 04:23 AM UTC

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

Ashok N [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;