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

Editing values n the Grid

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



9 Replies

KK Karthikraja Kalaimani Syncfusion Team February 23, 2023 11:35 AM UTC

Hi Abdul, 

We have prepared sample based on provided code snippets. The TextChanged event triggered whenever the text is changed. We have attached the tested sample and video for your reference. 

Regards,

Karthik Raja



Attachment: SfDataGridDemo_179db120.zip


AM Abdul Maajid Samad February 23, 2023 09:16 PM UTC

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/




KK Karthikraja Kalaimani Syncfusion Team February 24, 2023 12:18 PM UTC

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;
}



AM Abdul Maajid Samad February 24, 2023 03:22 PM UTC

Thanks. I was able to get the datarow using the


Completed="Entry_Completed"




KK Karthikraja Kalaimani Syncfusion Team February 27, 2023 01:12 PM UTC

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.



TF Thomas Fischer April 29, 2023 08:45 AM UTC

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



NY Nirmalkumar Yuvaraj Syncfusion Team May 2, 2023 01:14 PM UTC

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



KK Karthikraja Kalaimani Syncfusion Team May 4, 2023 01:12 PM UTC

Hi Thomas,

We have logged bug report for the reported issue "Keyboard disappears immediately when edit on Entry in DataGridTemplateColumn". We will fix the issue and include the fix in our upcoming weekly nuget release which is scheduled on 23rd May 2023. We appreciate your patience until then. 

Regards,
Karthik Raja


NY Nirmalkumar Yuvaraj Syncfusion Team May 23, 2023 01:14 PM UTC

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


Loader.
Up arrow icon