- Home
- Forum
- Xamarin.Forms
- App Crashes while adding column at runtime
App Crashes while adding column at runtime
hi,
We are trying to add column in SfdataGrid at runtime by calling-
DataGrid.Columns.Add(Column);
but getting below error-
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:161
at System.Collections.ObjectModel.Collection`1[T].get_Item (System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:46
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
--- End of inner exception stack trace ---
at Syncfusion.Data.Extensions.PropertyDescriptorExtensions.GetComplexPropertyValue (System.String[] propertyNameList, System.ComponentModel.PropertyDescriptorCollection tempItemProperties, System.Object record) [0x000c4] in <4aee0333a3c34836b1aa678458f427d4>:0
at Syncfusion.Data.ItemPropertiesProvider.GetValue (System.Object record, System.String property) [0x0005d] in <4aee0333a3c34836b1aa678458f427d4>:0
at Syncfusion.SfDataGrid.XForms.GridItemPropertiesProvider.GetValue (System.Object record, System.String propertyName) [0x00098] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.SfDataGridHelpers.GetCellValue (Syncfusion.SfDataGrid.XForms.SfDataGrid dataGrid, System.Object recordData, System.String columnName) [0x00025] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.GridCellTemplateRenderer.OnUpdateCellValue (Syncfusion.SfDataGrid.XForms.DataColumnBase dataColumn) [0x0001b] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.GridCellRendererBase.UpdateCellValue (Syncfusion.SfDataGrid.XForms.DataColumnBase dataColumn) [0x00000] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataColumn.OnInitializeColumnElement (System.Object rowData, System.Boolean isInEdit) [0x00018] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataColumnBase.InitializeColumnElement (System.Object rowData, System.Boolean isInEdit) [0x00000] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.CreateColumn (System.Int32 index, System.Int32 columnHeightIncrementation) [0x001ac] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.UpdateColumn (Syncfusion.SfDataGrid.XForms.DataColumnBase dc, System.Int32 index) [0x000e8] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.EnsureColumns (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumnLines) [0x00298] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.RowGenerator.EnsureColumns (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns) [0x00015] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.VisualContainer.EnsureItems (System.Boolean needToRefresh) [0x00052] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x00250] in <6f0e068f776b4ae0957413927afc420f>:0
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:784
at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:125
at Syncfusion.SfDataGrid.XForms.SfDataGrid.OnGridColumnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00428] in <6f0e068f776b4ae0957413927afc420f>:0
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338
at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196
at System.Collections.ObjectModel.Collection`1[T].Insert (System.Int32 index, T item) [0x00027] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:116
Parameter name: index
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:161
at System.Collections.ObjectModel.Collection`1[T].get_Item (System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:46
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
--- End of inner exception stack trace ---
at Syncfusion.Data.Extensions.PropertyDescriptorExtensions.GetComplexPropertyValue (System.String[] propertyNameList, System.ComponentModel.PropertyDescriptorCollection tempItemProperties, System.Object record) [0x000c4] in <4aee0333a3c34836b1aa678458f427d4>:0
at Syncfusion.Data.ItemPropertiesProvider.GetValue (System.Object record, System.String property) [0x0005d] in <4aee0333a3c34836b1aa678458f427d4>:0
at Syncfusion.SfDataGrid.XForms.GridItemPropertiesProvider.GetValue (System.Object record, System.String propertyName) [0x00098] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.SfDataGridHelpers.GetCellValue (Syncfusion.SfDataGrid.XForms.SfDataGrid dataGrid, System.Object recordData, System.String columnName) [0x00025] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.GridCellTemplateRenderer.OnUpdateCellValue (Syncfusion.SfDataGrid.XForms.DataColumnBase dataColumn) [0x0001b] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.GridCellRendererBase.UpdateCellValue (Syncfusion.SfDataGrid.XForms.DataColumnBase dataColumn) [0x00000] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataColumn.OnInitializeColumnElement (System.Object rowData, System.Boolean isInEdit) [0x00018] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataColumnBase.InitializeColumnElement (System.Object rowData, System.Boolean isInEdit) [0x00000] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.CreateColumn (System.Int32 index, System.Int32 columnHeightIncrementation) [0x001ac] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.UpdateColumn (Syncfusion.SfDataGrid.XForms.DataColumnBase dc, System.Int32 index) [0x000e8] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.DataRow.EnsureColumns (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumnLines) [0x00298] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.RowGenerator.EnsureColumns (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns) [0x00015] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.VisualContainer.EnsureItems (System.Boolean needToRefresh) [0x00052] in <6f0e068f776b4ae0957413927afc420f>:0
at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x00250] in <6f0e068f776b4ae0957413927afc420f>:0
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:784
at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:125
at Syncfusion.SfDataGrid.XForms.SfDataGrid.OnGridColumnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00428] in <6f0e068f776b4ae0957413927afc420f>:0
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338
at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196
at System.Collections.ObjectModel.Collection`1[T].Insert (System.Int32 index, T item) [0x00027] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:116
Regards,
SIGN IN To post a reply.
1 Reply
SS
Sivaraman Sivagurunathan
Syncfusion Team
July 27, 2020 07:56 AM UTC
Hi Rahul,
Thanks for using Syncfusion controls.
We have checked your reported issue from our side. Unfortunately, the issue does not reproduced from our side. From the stack trace, we suspect that, you have used the GridTemplateColumn and ComplexProperty in you sample. We have prepared the sample based on that. We have attached the tested sample for your reference you can download the same from the below link. If the issue still occurs from your side please revert us with modified sample.
Sample Link: https://www.syncfusion.com/downloads/support/forum/156350/ze/DataGridSample_(19)-538278169
Regards,
Sivaraman S
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
RR Rahul Rathore
- Jul 24, 2020 07:21 AM UTC
- Jul 27, 2020 07:56 AM UTC