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

Sorting of Items in Filter List is different than Grid Data Sorting

3 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pratik
Top achievements
Rank 1
Pratik asked on 15 Dec 2010, 08:49 AM
Hello
I am facing problem in the way items are displayed in Filter Screen.
Consider Grid having one of the column as Launch Name and 5 rows having following values for Launch Name column
ABC, 'ABC', (ABC), .ABC, [ABC]
Now When Grid is sorted based on Launch Name , it displays data in following order
'ABC'
(ABC)
.ABC
[ABC]
ABC

However when we click on Filter Icon of Launch Name column, we get list of items in following order
(ABC)
.ABC
[ABC]
ABC
'ABC'

Note that item with quotes was first in Grid Sorting, however it came last in Filter list.
I have attached screenshot depicting this behaviour.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Dec 2010, 09:15 AM
Hi,

 The grid filter distinct values are not sorted by default and will not respect the column sorting. 

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Pratik
Top achievements
Rank 1
answered on 15 Dec 2010, 09:37 AM
I do not agree that Grid Filter values are not sorted by default.
In the picture, one can see (except single quote), rest of values are sorted correctly in the Filter menu also, as per ASCII character
I am under impression that If sorting is based on ASCII, then at any place (either in Grid Data, Or in Filter Menu or any other place), it should show same result.
Waiting For Reply
0
Rossen Hristov
Telerik team
answered on 15 Dec 2010, 10:29 AM
Hello Pratik,

The distinct values are obtained by using the IQueryable.Distinct method. They are returned in the order that the particular IQueryProvider implements. We are not doing any sorting anywhere.

If you do not like the order in which they are returned you can very easily change it by attaching to the DistinctValuesLoading event and in the event handler set e.ItemsSource to a sorted copy of the distinct values. For example:

public MainPage()
{
    InitializeComponent();
 
    this.radGridView.DistinctValuesLoading += new EventHandler<Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs>(radGridView_DistinctValuesLoading);
}
 
void radGridView_DistinctValuesLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
    var distinctValues = this.radGridView.GetDistinctValues(e.Column, true);
     
    // Depending on the column type you can make the IEnumerable generic and "OrderBy" it.
    var sortedDistinctValues = <<sort them here somehow>>
    e.ItemsSource = sortedDistinctValues;
}

I hope this helps.

Kind regards,
Ross
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Pratik
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Pratik
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or