This is a migrated thread and some comments may be shown as answers.

Sorting Programmatically Created Columns Not Working

5 Answers 212 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Mar 2011, 06:39 PM
Hello, 

In my application, I have a RadGridView that contains columns that have been added via XAML as well as columns that are added dynamically in code.  The problem I am seeing is that the columns added via code cannot be sorted or grouped, while there is no problem with the columns created in XAML.  I have confirmed that the dynamically added columns have the IsSortable and IsGroupable properties set to true.  Should this be all I need?

One important difference is that the programmatically added columns contain more complex property names than do the columns added in XAML.  This results in the EffectiveSortMemberPath being set to something like "Experiments[0].WarpsPerBlock" (from the binding) on each of the dynamic columns.  Could the "deep" property string cause sorting to fail?

Any help will be greatly appreciated!

Thanks,
Mark


5 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 24 Mar 2011, 07:20 PM
Hello Mark,

 When you're binding to an indexer property and sorting, filtering or grouping do not work, it's because RadGridView was unable to determine the type of the value bound to. In this case you need to set the DataType property of your columns to the type of the object returned by the indexer property.

All the best,
Yavor Georgiev
the Telerik team
0
Mark
Top achievements
Rank 1
answered on 24 Mar 2011, 08:04 PM
Hi Yavor,

So, for my case, I need to set the DataType property on the column to the type of the object returned by "Experiments[0]" - is that correct?  I assume that is has to be an actual class that contains the identified property - in my case a class that has the property "WarpsPerBlock" - correct?

(I am asking because this is slightly different than what is required to simply display a value.  For example my Experiments list is a list of IExperimentResult, which does not actually have the WarpsPerBlock property.  The propertyvalue displays fine because (I assume) the grid is actually using reflection on the backing object to get the property value based on the property path.)

If so, I tried this and it is still not working.  I also tied setting the SortMemberPath explicitly to "WarpsPerBlock" in this example with no luck.  Am I missing something else?

Thanks,
Mark





0
Yavor Georgiev
Telerik team
answered on 24 Mar 2011, 08:21 PM
Hello Mark,

 RadGridView uses delegates constructed from LINQ expression trees to access the member value of an object, although it can fall back to Bindings if the LINQ runtime cannot construct the expression tree. LINQ is also used to execute sorting, grouping, etc. It seems that your case is rather more complex than usual and the runtime cannot construct the necessary expression tree. Would it be possible for you to open a separate support ticket and attach a small sample application reproducing this behavior?

Best wishes,
Yavor Georgiev
the Telerik team
0
Mark
Top achievements
Rank 1
answered on 24 Mar 2011, 08:26 PM
Hi Yavor,

Yes, I will try to construct and submit an example as soon as possible.  In the meantime, can you confirm that my previous post accurately describes what you were suggesting?

Thanks,
Mark
0
Yavor Georgiev
Telerik team
answered on 24 Mar 2011, 11:16 PM
Hello Mark,

 You need to set DataType to the type of the WarpsPerBlock property, not the type of the class that declares the property. Also, SortMemberPath is applied to the current data item, not to the value returned by the DataMemberBinding.

Best wishes,
Yavor Georgiev
the Telerik team
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or