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

sorting issue in filter distinct values loading..

1 Answer 14 Views
GridView
This is a migrated thread and some comments may be shown as answers.
karthikeyan
Top achievements
Rank 1
karthikeyan asked on 25 Aug 2016, 04:55 AM
Hi guys,
                I have an issue in distinct loading values  sorting method, The radgrid default sort order was none at the time itself the filter distinct values are sort by asc as default.
                I have done if the grid was desc then the distinct values are sort by desc as well as to Asc, but am facing an issue in the radgrid default sort order was none at the time the distinct values are sort by asc by default it should be sort by none. please help me in this issue, the code I used for sorting is



Private Sub grdMessages_DistinctValuesLoading(ByVal sender As Object, e As Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs) Handles grdMessages.DistinctValuesLoading

Dim gridView = TryCast(sender, RadGridView)
If e.Column.SortingState = SortingState.Descending Then
e.ItemsSource = gridView.GetDistinctValues(e.Column, True).OfType(Of String)().OrderByDescending(Function(x) x)
ElseIf e.Column.SortingState = SortingState.Ascending Then
e.ItemsSource = gridView.GetDistinctValues(e.Column, True).OfType(Of String)().OrderBy(Function(x) x)
ElseIf e.Column.SortingState = SortingState.None Then
e.ItemsSource = ? 'confused in this part
End If
End Sub

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 26 Aug 2016, 09:44 AM
Hello Karthikeyan,

You can work with the Items collection of the RadGridView:

ElseIf e.Column.SortingState = SortingState.None Then
        e.ItemsSource = clubsGrid.Items.Cast(Of Club)().[Select](Function(x) x.Name).Distinct()

The code snippet considers a scenario where the RadGridView  control is bound to a collection of Club objects and the filtering is applied the "Name" column(bound to Name property). You can consider such approach for your specific setup and the different columns.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
karthikeyan
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or