Hi,
Is there a celledit template so we can edit and track the changes in the viewmodel? Place an Entry control for example in the template and then subscribe to the Text changed event. I am trying to get it to to work in cell template and it is not working.
<sfgrid:DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<Label
Margin="{OnPlatform WinUI='0,16,0,15',
MacCatalyst='0,16,0,15',
Android='10,8,0,7',
iOS='10,8,0,7'}"
FontAttributes="Bold"
FontFamily="Roboto-Medium"
FontSize="14"
HorizontalOptions="Start"
Text="Qty"
VerticalOptions="Center" />
</DataTemplate>
</sfgrid:DataGridTemplateColumn.HeaderTemplate>
<sfgrid:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Entry
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
Keyboard="Numeric"
TextChanged="Qty_TextChanged"
Text="{Binding OrderQty, Mode=TwoWay}" />
</DataTemplate>
</sfgrid:DataGridTemplateColumn.CellTemplate>
</sfgrid:DataGridTemplateColumn>
Thanks
Karthik Raja
Hi,
Thanks for the reply. There was no problem with the Text event triggering , however the value passed in 'e' is only the Text , oldvalue and newvalue. I want to see the row as well which was edited. Without that there is no reference to the row that was edited that can be then updated in the view model.
I also tried saving the selected row in the vm as
private void dataGrid_SelectionChanged(object sender, Syncfusion.Maui.DataGrid.DataGridSelectionChangedEventArgs e)
{
vm.SelectedInvoiceItem = (InvoiceItem)e.AddedRows[0];
}
then update that reference in the Qty_Changed event. For that to work, the row has to be selected first. If not the incorrect row is updated.
I see that the grid in maui is not supporting "Editing" as in xamarin yet. When it supports then I can get the functionality that I am expecting. Till then I will use a workaround/
The edited row details can be obtained from the Entry's BindingContext on its TextChanged event. Refer to the below code snippet for the same.
Code snippet :
private void Entry_TextChanged(object sender, TextChangedEventArgs e) { var currentRow = (sender as Entry).BindingContext; } |
Thanks. I was able to get the datarow using the
Completed="Entry_Completed"
We are glad that your requirement has been met on your side. Please let us know if you need further assistance. As always, we are happy to help you out.
I today tested the attached demo-project in the zip-file with Maui-DataGrid V 21.1.41.
With that approach I cannot enter text on an IPad - the virtual keyboard is shortly visible, but then disappears directly.
Even an a Mac, I have to select the entry-field twice to be able to enter text.
Regards
Thomas
Hi Thomas,
Currently we are validating your requirement. We will validate and update the further details on or before 4th May 2023. We appreciate your patience until then.
Regards,
Nirmalkumar
Hi Thomas,
We are glad to inform you that the fix has been included in our weekly NuGet release for the mentioned issue. Please update the Syncfusion.Maui.DataGrid package to version 21.2.6.
https://www.nuget.org/packages/Syncfusion.Maui.DataGrid
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.
Regards,
Nirmalkumar