How to trigger end edit on done key in NET MAUI DataGrid?
In this article, we will show you how to trigger the CurrentCellEndEdit event in a .NET MAUI DataGrid when tap the Done key on the Android soft keyboard.
In SfDataGrid, by extending the DataGridTextBoxCellRenderer and handling the Entry.Completed event, we can detect when the Done key is pressed on the Android soft keyboard. By programmatically calling EndEdit() within this event, the cell editing session is properly ended, which in turn automatically triggers the CurrentCellEndEdit event on the DataGrid.
C#
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
sfGrid.CellRenderers.Remove("Text");
sfGrid.CellRenderers.Add("Text", new CustomTextRenderer());
}
private void sfGrid_CurrentCellEndEdit(object sender, Syncfusion.Maui.DataGrid.DataGridCurrentCellEndEditEventArgs e)
{
}
}
public class CustomTextRenderer : DataGridTextBoxCellRenderer
{
public override void OnInitializeEditView(DataColumnBase dataColumn, SfDataGridEntry view)
{
base.OnInitializeEditView(dataColumn, view);
if (view != null && view is Entry entry)
{
entry.Completed += Entry_Completed;
}
}
private void Entry_Completed(object? sender, EventArgs e)
{
DataGrid.EndEdit();
}
}
You can download this example on GitHub.
Conclusion
I hope you enjoyed learning about how to trigger end edit on done key in NET MAUI DataGrid.
You can refer to our .NET MAUI DataGrid’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums,Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!