Testing the Datagrid, I see that you have to double tap (or click on WIndows) to select a cell for editing.
Is there a way for the user to only click the cell once to enter edit mode, or any workaround for this? The current flow is a bit counter intuitive.
Thanks
1 Answer, 1 is accepted
1
Accepted
Didi
Telerik team
answered on 01 Aug 2024, 08:46 AM
Hi Andres,
By default, the DataGrid enters edit mode on cell double tap. You can modify that behavior by handling CellTap Command and executing the CellDoubleTap default logic instead, here is a quick example:
DataGrid definition:
<telerik:RadDataGridx:Name="grid"/>
Page's code behind:
publicpartialclassMainPage : ContentPage
{
publicMainPage()
{
InitializeComponent();
var data = new ObservableCollection<Data>();
for (int i = 0; i < 10; i++)
{
data.Add(new Data { Id = i, Name = "Name" + i});
}
this.grid.ItemsSource = data;
this.grid.Commands.Add(new CellTapUserCommand());
}
}
publicclassData
{
publicint Id { get; set; }
publicstring Name { get; set; }
}
In this way, the editing will be triggered as soon as the user clicks/tap on a cell. In general, the cell updated value should be committed as soon as it exits the edit mode (clicking outside the entry, for example).
Side note: I noticed you open only forum threads. You can also open support tickets if you have a trial or commercial license. Please have this in mind. I can suggest you open support tickets for the questions you have.
Hi Didi thanks for your response. I will go ahead and post a ticket, but in the meantime, I tried implementing your solution, however, I can't access my datagrid from code-behind It gives this error:
As you can see, I'm also using MVVM, so I don't know if that changes things up a bit. Thanks
Lance | Senior Manager Technical Support
Telerik team
commented on 02 Aug 2024, 06:01 PM
Hi Andres, are you sure that you're on the same page as the DataGrid is in XAML? That screenshot shows "BasePage", which is usually not used as a front level page with UI elements in it, so I wanted just to double check this with you and that the MyDataGrid is in fact defined on BasePage.xaml.
An alternative approach to use is to add the command in XAML:
<telerik:RadDataGrid><telerik:RadDataGrid.Commands><!-- This being the instance of your custom command type --><local:MyCellTapCommand /></telerik:RadDataGrid.Commands></telerik:RadDataGrid>