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

Datagrid Sort on expandoObject

I need to create columns at runtime. The requirements are that at runtime we don’t know how many columns we will have.  For this we used either a dictionary or an ExpandoObject, which implements the IDictionary interface internally, with no success.

Although the data is visible using the MappingName, we cannot use the default sorting and grouping from the DataGrid.

Mapping using the Dictionary approach (where index 0 resembles an ID field):

grdTest.Columns.Add(new GridTextColumn() { Width = 150, HeaderText = "ID", MappingName = "Properties[0]" });

or using the ExpandoObject approach:

grdTest.Columns.Add(new GridTextColumn() { Width = 150, HeaderText = "ID", MappingName = "ID" });

 

We get the following exception when we click on a header to sort the grid.

System.ArgumentException

   at System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName)

   at Syncfusion.Linq.QueryableExtensions.GetValueExpression(ParameterExpression paramExpression, String propertyName, Type sourceType)

   at Syncfusion.Linq.QueryableExtensions.GetLambdaWithComplexPropertyNullCheck(IQueryable source, String propertyName, ParameterExpression paramExpression)

   at Syncfusion.Linq.QueryableExtensions.OrderBy(IQueryable source, String propertyName, Type sourceType)

   at Syncfusion.WinRT.Data.QueryableCollectionView.SortQueryable(IQueryable source)

   at Syncfusion.WinRT.Data.QueryableCollectionView.RefreshSort()

   at Syncfusion.WinRT.Data.CollectionViewAdv.EndDeferInternal()

   at Syncfusion.WinRT.Data.CollectionViewAdv.EndDefer()

   at Syncfusion.WinRT.Data.CollectionViewAdv.DeferHelper.Dispose()

   at Syncfusion.WinRT.Data.CollectionViewAdv.EndInit()

   at Syncfusion.UI.Xaml.Grid.GridModel.MakeSort(GridColumn Column, ListSortDirection direction)

   at Syncfusion.UI.Xaml.Grid.GridHeaderCellControl.Sort()

   at Syncfusion.UI.Xaml.Grid.GridHeaderCellControl.OnTapped(TappedRoutedEventArgs e)

 


7 Replies

PS Prakash Selvaraj Syncfusion Team March 27, 2013 12:34 PM UTC

Hi Marco,

 

Sorry for this inconvenience caused.

 

As of now we have not provided support for dynamic objects. We have planned to implement the Dynamic Object support in our next release, our next release will be available in middle of May 2013.

 

This exception occurs since we are using reflection to get the value from the objects that are bound to the DataGrid. In your case, by using the reflection we are not able to get the value from the Dynamic Objects (ExpandoObject). So, while clicking the column header DataGrid will throw the exception. Currently to avoid that exception, you can disable the sorting and grouping option in DataGrid.

 

Please let us know if you need further assistance.

 

Regards,

Prakash S.



PS Prakash Selvaraj Syncfusion Team May 27, 2013 05:48 PM UTC

Hi Marco,

 

We are glad to announce that our  Essential Studio Vol 2 2013 is rolled out and is available for download under the following link

 

http://www.syncfusion.com/support/forums/general/108998/Essential-Studio-2013-Volume-2-Final-Release-v112025-available-for-download-

 

 Please find the release notes in the following link

https://s3.amazonaws.com/files2.syncfusion.com/Installs/v11.2.0.25/ReleaseNotes/WinRT.html

 

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

 

Regards,

Prakash S.




MA marco June 5, 2013 03:10 PM UTC

Hi, I implemented the datagrid with dynamic objects as datasource.  At first glance everything seems to work fine.  But when I move columns or scroll horizontally or group the data, the data is not shown correctly anymore.   A quick example:  

After initial load: 
Property 1             Property 2                Property 3                Property 4

1                            1                                    1                                1
2                            2                                    2                                2
3                            3                                    3                                3
4                            4                                    4                                4


After column Switch

Property 3             Property 1                Property 2                Property 4

1                            1                                    1                                1
2                            2                                    2                                2
3                            3                                    3                                3
1                          4                                    4                                4

If i check the datasource in codebehind after the column switch, everything is as it should be.
Any idea what could be the problem?

br
Marco



DV Dineshprabhu V Syncfusion Team June 11, 2013 06:46 AM UTC

Hi Marco,

 

Sorry for the inconvenience caused.

 

We have analyzed the reported issue with our sample; we are not able to reproduce the issue. Could you please check the below sample?

 

Sample: http://www.syncfusion.com/downloads/Support/DirectTrac/91540/SampleTest822887180.zip

 

We suspect you are using our grid in some other scenario, could you please modify our sample and revert with the replication procedure, which would be very helpful to resolve the issue.

 

Please let us know if you have any concerns.

 

Thank you,

Dineshprabhu V

 



MA marco June 12, 2013 08:42 AM UTC

Hi,

I managed to recreate my problem with your application. (see attachment)

The main difference is that you declare the columns in xaml, where I create them in codebehind (depending on the number (and names)  of properties of the dynamic object.  That's also the reason why I need a dynamic object, because I don't know how many properties there will be and what the names of those properties will be...

 

br,

Marco



SampleTest_58040fb8.zip


DV Dineshprabhu V Syncfusion Team June 14, 2013 12:52 PM UTC

Hi Marco,

 

Sorry for the inconvenience caused.

 

We have considered the reported problem as a defect in our source and a fix for this defect will be included in the upcoming service pack which will be available in next week.

 

Please let us know if you have any concerns.

 

Thank you,

Dineshprabhu v



SN Sankara Narayanan N Syncfusion Team June 28, 2013 12:57 PM UTC

Hi Marco,

 We are glad to announce that our Essential Studio Vol 2 service pack 2013 is rolled out and is available for download under the following link.

 http://www.syncfusion.com/support/forums/winrt/109691/Syncfusion-Essential-Studio-for-WinRT-%28XAML%29-v112029-%28Service-Pack%29-available-for-download-

 We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

 Regards,

Sankar


Loader.
Live Chat Icon For mobile
Up arrow icon