Grid exception only on IOS

hi all,

i'm using your last release and i hjave a bug just on IOS with the grid.

can you check this please?


- $exception {System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

  at System.Collections.Generic.List`1+Enumerator[T].MoveNextRare () [0x00013] in <e5cc3f1c59b64ff0909f04d8b24b7bfa>:0

  at System.Collections.Generic.List`1+Enumerator[T].MoveNext () [0x0004a] in <e5cc3f1c59b64ff0909f04d8b24b7bfa>:0

  at Syncfusion.SfDataGrid.XForms.VisualContainer.ArrangeRows () [0x00a7b] in <ab9225734220474ca1b60cd4e579a198>:0

  at Syncfusion.SfDataGrid.XForms.VisualContainer.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00000] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x0054f] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157

  at Syncfusion.SfDataGrid.XForms.ExtendedScrollView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00121] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Syncfusion.SfDataGrid.XForms.ExtendedScrollView.OnSizeAllocated (System.Double width, System.Double height) [0x0000e] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:107

  at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x004f7] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:107

  at Syncfusion.SfDataGrid.XForms.GridColumnSizer.RefreshColumnSizer (System.Double viewSize) [0x000cf] in <ab9225734220474ca1b60cd4e579a198>:0

  at Syncfusion.SfDataGrid.XForms.RowGenerator.ApplyColumnSizer (System.Double viewSize) [0x0000b] in <ab9225734220474ca1b60cd4e579a198>:0

  at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x001e2] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157

  at Syncfusion.SfDataGrid.XForms.ExtendedScrollView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00121] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Syncfusion.SfDataGrid.XForms.ExtendedScrollView.OnSizeAllocated (System.Double width, System.Double height) [0x0000e] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Syncfusion.SfDataGrid.XForms.SfDataGrid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x000e3] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Syncfusion.SfDataGrid.XForms.SfDataGrid.OnSizeAllocated (System.Double width, System.Double height) [0x0001f] in <ab9225734220474ca1b60cd4e579a198>:0

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157

  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00150] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:43

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157

  at Xamarin.Forms.ScrollView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x000f8] in D:\a\1\s\Xamarin.Forms.Core\ScrollView.cs:237

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.View child, Xamarin.Forms.Rectangle region, Xamarin.Forms.SizeRequest childSizeRequest) [0x00225] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:291

  at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00081] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:65

  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239

  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157

  at Xamarin.Forms.Page.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0010d] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:296

  at Xamarin.Forms.Page.UpdateChildrenLayout () [0x000ca] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:375

  at Xamarin.Forms.Page.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:355

  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:872

  at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1104

  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:411

  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:781

  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElementSize (Xamarin.Forms.Size size) [0x0004a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:150

  at Xamarin.Forms.Platform.iOS.ModalWrapper.ViewDidLayoutSubviews () [0x00006] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ModalWrapper.cs:108

  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)

  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:69

  at TestApp.iOS.Application.Main (System.String[] args) [0x00001] in D:\Dev\Updater\TestApp\TestApp.iOS\Main.cs:17 } System.InvalidOperationException




4 Replies

SV Suja Venkatesan Syncfusion Team October 12, 2021 02:38 PM UTC

Hi Alberto, 

Thank you for contacting Syncfusion support. 

We checked the reported issue “Grid Exception only on iOS” in simple sample with Datagrid but unfortunately we are unable to reproduce the issue in our end. We are unclear about the scenario in which you are facing this exception (For example : Either on initial loading or while making any interagtion in the SfDataGrid). The sample we have used to check this issue is available in the following link for your reference. 


Please have a look at this sample and let us know if you are facing the same issue in this same too. If not revert to us with a modified sample to reproduce the issue or provide the below mentioned details. 

  1. All the XAML and C# code snippet related to SfDataGrid
  2. Video illustration of the issue, if possible.
  3. Share scenario when exception gets thrown.
 
Please revert to us with all the above requested details. It will be more helpful for us to find the exact cause for the issue and prompt solution at earlier. 

Additional Information: 
Tested Device: VisualStudio Emulator(iPhone-8 (iOS-14.4)) 
SfDataGrid version: 19.3.0.44 
Xamarin.Forms version: 5.0.0.2125.


LU Luca October 14, 2021 01:55 PM UTC

hi,

the issue start from here (just on IOS, android works)

thanks


grid.QueryRowHeight += DataGrid_QueryRowHeight;


private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e)

        {

var tab = sender as SfDataGrid;

            if (tab.View.Records.Count == 0 && e.RowIndex == 0)

             tab.HeightRequest = e.Height;

             else

             if (e.RowIndex == 1)

             tab.HeightRequest = e.Height * (tab.View.Records.Count + 1);

}



SV Suja Venkatesan Syncfusion Team October 15, 2021 03:00 PM UTC

Hi Luca, 

Sorry for the inconvenience caused. 

We would like to let you know that we are able to reproduce the reported issue in our end. We are currently validating this. We are in need of two more business days to validate this properly. We will update the further detail on October 19, 2021. We appreciate your patience until then. 

Regards, 
Suja


SV Suja Venkatesan Syncfusion Team October 19, 2021 03:10 PM UTC

Hi Luca, 

Thanks for your patience. 

We have suspect you tried to set the Height for the SfDatagrid based on the row count. You can achieve your requirement by setting height to the datagrid in SfDatagrid loaded event as like below code snippet. 

Code Snippet: 
datagrid.GridLoaded += Datagrid_GridLoaded; 
private void Datagrid_GridLoaded(object sender, GridLoadedEventArgs e)
{
var tab = sender as SfDataGrid;
if (tab.View.Records.Count == 0)
{
tab.HeightRequest = tab.RowHeight;
}
else
tab.HeightRequest = tab.RowHeight * (tab.View.Records.Count + 1); 

The QueryRowHeight event will be fired each time a row comes into view and we are unclear about your usecase. Can you please explain in details about your usecase, setting the  Height for the Datagrid inside the QueryRowHeight event. It will be more helpful for us to provide a prompt solution at earlier. 

Regards, 
Suja. 


Loader.
Up arrow icon