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

RadGridView sorting does not work properly in case converters are applied

3 Answers 336 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tijana
Top achievements
Rank 1
Tijana asked on 27 Jan 2015, 11:00 AM
Hello,
We have a problem with column sorting in case column uses converter to display values.
For example:
There is a grid column:
<telerik:GridViewDataColumn DataMemberBinding="{Binding NameToDisplay,
Converter={StaticResource<BR>SimpleLocalizationConverter}}"Width="Auto"><BR><BR></telerik:GridViewDataColumn

Property NameToDisplay is bound to column and it may contains the following values:

Item1, Item2… Item10, Item11… Item20, Item21…

When converter is applied displayed values are:

Item001, Item002… Item010, Item011… Item020, Item021…

The problem is occurring in case sorting is applied.

Instead of having following list of items: Item001, Item002… Item010,
Item011… Item020, Item021… after sorting is performed we have:

Item001, Item010, Item011… Item002, Item020, Item021…

Apparently, sorting works based on bound data, not converted
ones. 

Please advise if there is an appropriate way to avoid this
behaviour?
I cannot change values which are bound to the column and I
would like to avoid custom sorting if it is possible.

Thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Jan 2015, 08:52 AM
Hi Tijana,

All data operations like sorting, filtering, grouping, etc. are performed based on the data bound properties. One way to go would be to set SortMemberPath property of your column and set it to another property from your business object.  You can create a ViewModel to your business object and expose another property that holds the converted values. Then you can either bind directly to it or set SortMemberPath to that specific property. 
Other option, like you said, is to customize the sorting and implement your own custom logic. 

Regards,
Maya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tijana
Top achievements
Rank 1
answered on 03 Feb 2015, 12:59 PM
Thank you Maya.

We solved problem by using GridViewExpressionColumn instead of GridViewDataColumn.
0
Andrew
Top achievements
Rank 1
answered on 27 May 2020, 01:32 PM

Hi,

We have the some issue, we need to enable sort column with Converter for DataMemberBinding.
How you use the GridViewExpressionColumn to enable sorting with Converter for Expression colomn?

Thanks

Tags
GridView
Asked by
Tijana
Top achievements
Rank 1
Answers by
Maya
Telerik team
Tijana
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or