sorting issue in filter distinct values loading..

2 posts, 0 answers
  1. karthikeyan
    karthikeyan avatar
    12 posts
    Member since:
    Aug 2016

    Posted 24 Aug Link to this post

    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
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    281 posts

    Posted 26 Aug Link to this post

    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 over 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.
  3. DevCraft banner
Back to Top