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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfDataGrid support for dynamic/ExpandoObject - ArgumentOutOfRangeException

Thread ID:

Created:

Updated:

Platform:

Replies:

119705 Jul 15,2015 04:18 PM UTC Jul 27,2015 05:20 PM UTC WPF 7
loading
Tags: SfDataGrid
Stebay
Asked On July 15, 2015 04:18 PM UTC

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



Jayapradha S [Syncfusion]
Replied On 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

Stebay
Replied On 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

Jayapradha S [Syncfusion]
Replied On 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



Stebay
Replied On 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


Kanimozhi Pandian [Syncfusion]
Replied On 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.

Stebay
Replied On 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

Jayapradha S [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;