sfDataGrid support for dynamic/ExpandoObject - ArgumentOutOfRangeException
Hi
I can successfully create a list of ExpandoObjects then create an ObservableCollection to wrap these, and then bind to this.
However if I first create the ObservableCollection, then add ExpandoObjects to this I get ArgumentOutOfRangeException, stack trace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Syncfusion.Data.EnumerableRecordsWrapper.get_Item(Int32 index)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumnsForDynamic(Columns columns, ICollectionViewAdv view)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumns(Columns columns, ICollectionViewAdv view)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumns()
at Syncfusion.UI.Xaml.Grid.GridModel.OnViewPropertyChanged(Object sender, PropertyChangedEventArgs e)
at Syncfusion.Data.CollectionViewAdv.RaisePropertyChanged(String propertyName)
at Syncfusion.Data.CollectionViewAdv.SetItemProperties(IEnumerable dataSource)
at Syncfusion.Data.CollectionViewAdv.SourceNotifyCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at CallSite.Target(Closure , CallSite , ObservableCollection`1 , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
at Profound.Mining.ViewModel.Foundation.Sub.DataInputGridViewModel.ExecuteSFDynamicCommand() in v:\Profound.Mining.Base\Profound.Mining.ViewModel.Foundation\Sub\DataInputGridViewModel.cs:line 188
Scenario
My sfDataGrid is binding to a property on my ViewModel with the attribute ItemsSource="{Binding GridData}
my ViewModel GridData property is typed:
public ObservableCollection<Object> GridData (implements INPC)
Code that works (create list of ExpandoObject, then create ObservableCollection from it)
dynamic newRow;
var data = new List<Object>();
newRow = new ExpandoObject();
newRow.Name = "Chickens";
newRow.When = new DateTime(2014, 1, 1);
newRow.HowMany = 4;
data.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Geese";
newRow.When = new DateTime(2014, 6, 14);
newRow.HowMany = 2;
data.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Swans";
newRow.When = new DateTime(2015, 2, 14);
newRow.HowMany = 3;
data.Add(newRow);
GridData = new ObservableCollection<object>(data);
Code that does not work (create ObservableCollection first, then add rows directly to it)
dynamic newRow;
GridData = new ObservableCollection<object>();
newRow = new ExpandoObject();
newRow.Name = "Chickens";
newRow.When = new DateTime(2014, 1, 1);
newRow.HowMany = 4;
GridData.Add(newRow); //ArgumentOutOfRangeException on this line
newRow = new ExpandoObject();
newRow.Name = "Geese";
newRow.When = new DateTime(2014, 6, 14);
newRow.HowMany = 2;
GridData.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Swans";
newRow.When = new DateTime(2015, 2, 14);
newRow.HowMany = 3;
GridData.Add(newRow);
I have seen other threads on using dynamic/ExpandoObject data for sfDataGrid and these suggest you have added support for these.
Thanks
Steve
I can successfully create a list of ExpandoObjects then create an ObservableCollection to wrap these, and then bind to this.
However if I first create the ObservableCollection, then add ExpandoObjects to this I get ArgumentOutOfRangeException, stack trace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Syncfusion.Data.EnumerableRecordsWrapper.get_Item(Int32 index)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumnsForDynamic(Columns columns, ICollectionViewAdv view)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumns(Columns columns, ICollectionViewAdv view)
at Syncfusion.UI.Xaml.Grid.SfDataGrid.GenerateGridColumns()
at Syncfusion.UI.Xaml.Grid.GridModel.OnViewPropertyChanged(Object sender, PropertyChangedEventArgs e)
at Syncfusion.Data.CollectionViewAdv.RaisePropertyChanged(String propertyName)
at Syncfusion.Data.CollectionViewAdv.SetItemProperties(IEnumerable dataSource)
at Syncfusion.Data.CollectionViewAdv.SourceNotifyCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at CallSite.Target(Closure , CallSite , ObservableCollection`1 , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
at Profound.Mining.ViewModel.Foundation.Sub.DataInputGridViewModel.ExecuteSFDynamicCommand() in v:\Profound.Mining.Base\Profound.Mining.ViewModel.Foundation\Sub\DataInputGridViewModel.cs:line 188
Scenario
My sfDataGrid is binding to a property on my ViewModel with the attribute ItemsSource="{Binding GridData}
my ViewModel GridData property is typed:
public ObservableCollection<Object> GridData (implements INPC)
Code that works (create list of ExpandoObject, then create ObservableCollection from it)
dynamic newRow;
var data = new List<Object>();
newRow = new ExpandoObject();
newRow.Name = "Chickens";
newRow.When = new DateTime(2014, 1, 1);
newRow.HowMany = 4;
data.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Geese";
newRow.When = new DateTime(2014, 6, 14);
newRow.HowMany = 2;
data.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Swans";
newRow.When = new DateTime(2015, 2, 14);
newRow.HowMany = 3;
data.Add(newRow);
GridData = new ObservableCollection<object>(data);
Code that does not work (create ObservableCollection first, then add rows directly to it)
dynamic newRow;
GridData = new ObservableCollection<object>();
newRow = new ExpandoObject();
newRow.Name = "Chickens";
newRow.When = new DateTime(2014, 1, 1);
newRow.HowMany = 4;
GridData.Add(newRow); //ArgumentOutOfRangeException on this line
newRow = new ExpandoObject();
newRow.Name = "Geese";
newRow.When = new DateTime(2014, 6, 14);
newRow.HowMany = 2;
GridData.Add(newRow);
newRow = new ExpandoObject();
newRow.Name = "Swans";
newRow.When = new DateTime(2015, 2, 14);
newRow.HowMany = 3;
GridData.Add(newRow);
I have seen other threads on using dynamic/ExpandoObject data for sfDataGrid and these suggest you have added support for these.
Thanks
Steve
SIGN IN To post a reply.
7 Replies
JS
Jayapradha S
Syncfusion Team
July 16, 2015 09:51 AM UTC
Hi Stephen,
Thank you for contacting Syncfusion support.
We analyzed your stack trace with code snippet which you have shared and we are able to replicate the issue in 13.1V. We have fixed the issue “Argument out of range exception” in our latest version, Could you please upgrade to our latest version 13.2.0.29V and check the same issue at your end?
Please let us know if you require any other assistance.
Regards,
Jayapradha
Thank you for contacting Syncfusion support.
We analyzed your stack trace with code snippet which you have shared and we are able to replicate the issue in 13.1V. We have fixed the issue “Argument out of range exception” in our latest version, Could you please upgrade to our latest version 13.2.0.29V and check the same issue at your end?
Please let us know if you require any other assistance.
Regards,
Jayapradha
ST
Stebay
July 16, 2015 02:23 PM UTC
Hi Jayapradha
I've upgraded to the latest version, but I am getting the same exception and same stack trace.
To make sure I have the correct version, Syncfusion.Grid.Wpf.dll is version 13.2450.0.29
NuGet reports version:
ID Syncfusion.Grid.WPF45
Version: 13.2.0.29
Steve
I've upgraded to the latest version, but I am getting the same exception and same stack trace.
To make sure I have the correct version, Syncfusion.Grid.Wpf.dll is version 13.2450.0.29
NuGet reports version:
ID Syncfusion.Grid.WPF45
Version: 13.2.0.29
Steve
JS
Jayapradha S
Syncfusion Team
July 20, 2015 01:07 PM UTC
Hi Steve,
Thank you for your update.
We have analyzed the details in your previous update and found that the Grid.WPF45 Nuget package has been installed. Please install the Syncfusion.SfGrid.WPF45 to install the SfDataGrid control assemblies in 13.2.0.29V and also ensure the assembly version of SfDataGrid in 13.2.0.29V.
Please find the sample from the below location.
Sample Link: ExpandoObject
Kindly let us know if you require any further assistance on this.
Regards,
Jayapradha
Thank you for your update.
We have analyzed the details in your previous update and found that the Grid.WPF45 Nuget package has been installed. Please install the Syncfusion.SfGrid.WPF45 to install the SfDataGrid control assemblies in 13.2.0.29V and also ensure the assembly version of SfDataGrid in 13.2.0.29V.
Please find the sample from the below location.
Sample Link: ExpandoObject
Kindly let us know if you require any further assistance on this.
Regards,
Jayapradha
ST
Stebay
July 21, 2015 10:55 AM UTC
Thanks - you are right, I had Grid.WPF45 installed and not the latest version of SfGrid.WPF45.
However I can't get the latest version of SfGrid.WPF45 from your nuget feed - the latest version on there is 13.1.0.21
I am getting the feed URL by logging in at http://nuget.syncfusion.com/ and using the URL from the "WPF" section.
I have tried manually pasting in the packages in your test project (from packages.config) but nuget then complains it cannot find the right version.
Could you update your nuget feed and I will retest with the latest version.
Thanks
Steve
KP
Kanimozhi Pandian
Syncfusion Team
July 22, 2015 12:25 PM UTC
Hi Steve,
Sorry about the inconvenience caused.
We have refreshed the SfGrid.WPF NuGet Packages in our Syncfusion NuGet server. Now you can able to update the latest Packages from the Syncfusion NuGet Server.
Please let me know if you have any queries.
Thanks,
Kanimozhi.K.P.
Sorry about the inconvenience caused.
We have refreshed the SfGrid.WPF NuGet Packages in our Syncfusion NuGet server. Now you can able to update the latest Packages from the Syncfusion NuGet Server.
Please let me know if you have any queries.
Thanks,
Kanimozhi.K.P.
ST
Stebay
July 23, 2015 09:51 AM UTC
Thanks - I have updated to the new version, and your demo code works fine.
However in my code I am not specifying the column bindings in the XAML (as I want the columns to be auto-generated from the data) - in that circumstance if I update the grid by creating a List<object>(), adding ExpandoObject rows to that, and then creating an ObservableCollection from the list, it shows just fine.
However if I create the ObservableCollection first, assign it to the grid, and then add items, these are not shown.
I have updated your sample code to include this, it is attached - one button works, the other does not.
Thanks
Steve
Attachment: ExpandoObjectsfGrid20150723_a315e9a5.zip
However in my code I am not specifying the column bindings in the XAML (as I want the columns to be auto-generated from the data) - in that circumstance if I update the grid by creating a List<object>(), adding ExpandoObject rows to that, and then creating an ObservableCollection from the list, it shows just fine.
However if I create the ObservableCollection first, assign it to the grid, and then add items, these are not shown.
I have updated your sample code to include this, it is attached - one button works, the other does not.
Thanks
Steve
Attachment: ExpandoObjectsfGrid20150723_a315e9a5.zip
JS
Jayapradha S
Syncfusion Team
July 27, 2015 05:20 PM UTC
Hi Steve,
We are sorry about the inconvenience.
We were able to reproduce the problem. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Please let me know if you have any questions.
Regards,
Jayapradha
We are sorry about the inconvenience.
We were able to reproduce the problem. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Please let me know if you have any questions.
Regards,
Jayapradha
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
-
ST Stebay
- Jul 15, 2015 04:18 PM UTC
- Jul 27, 2015 05:20 PM UTC