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

[Solved] Custom Sorting and Sort Indicators

1 Answer 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian
Top achievements
Rank 1
Brian asked on 22 May 2013, 04:20 PM
Hi,

I am doing custom sorting on a RadGridView and have a question about the sort indicators. When I implement custom sorting code similar to the example here, the previously sorted column's indicator does not clear when a new column is sorted, as if you were doing multi column sorting. This happens regardless of what the IsCustomSortingEnabled property is set to. I can work around this by looping through the column collection and setting the sorting state to none for the appropriate columns during the Sorting event. A sample of my sorting code is below.

Is the need to manually clear the sort indicators expected functionality? Also, can you explain what the IsCustomSortingEnabled property does? The documentation does not really provide much info.

Thanks.

private void Grid_Sorting(object sender, GridViewSortingEventArgs e)
{
    if (e.OldSortingState == SortingState.None)
    {
        e.NewSortingState = SortingState.Ascending;
        //Call Custom Sort Logic
    }
    else if (e.OldSortingState == SortingState.Ascending)
    {
        e.NewSortingState = SortingState.Descending;
        //Call Custom Sort Logic
    }
    else
    {
        e.NewSortingState = SortingState.None;
       //Call Custom Sort Logic
    }
 
    e.Cancel = true;
}

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 27 May 2013, 02:12 PM
Hello,

Actually this property does not affect the sorting directly. When you implement a custom sorting, then you should ensure in your implementation that the previous SortDescriptors are cleared before a new one is added.

You can use this property to set an initial SortingState for the column as demonstrated on this help article.

Regards,
Didie
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Brian
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or