Display Filtered Records

5 posts, 1 answers
  1. Dongzhi
    Dongzhi avatar
    25 posts
    Member since:
    Jan 2014

    Posted 01 Oct 2014 Link to this post

    I have a scenario where I have a grid with 20 columns. When the user filters on any columns of the I want a label to display which columns are filtered. How can I do that in the grid? I tried using the Filtered event but got stuck:

            protected void TelerikGridFiltered(object sender, GridViewFilteredEventArgs e)
            {
                filterRecordText.Text = e.ColumnFilterDescriptor.Column.Name;
            }

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 06 Oct 2014 Link to this post

    Hello,

    The Filtered event should be raised every time the user applies filtering on any column. Then all the information on the applied filtering criteria is available through RadGridView.FilterDescriptors collection.
    Would you please share some more details on what do you mean as you say that you get stuck?

    Regards,
    Dimitrina
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. Dongzhi
    Dongzhi avatar
    25 posts
    Member since:
    Jan 2014

    Posted 07 Oct 2014 in reply to Dimitrina Link to this post

    I don't know how loop through the FilterDescriptors collection for the filtered column names and display them to the user.
  4. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 08 Oct 2014 Link to this post

    Hello,

    You could extract the data and populate it as a Text for the defined TextBlock similar to:
    private void clubsGrid_Filtered(object sender, GridViewFilteredEventArgs e)
    {
        if (clubsGrid.FilterDescriptors.Count == 0)
        {
            filteredText.Text = string.Empty;
            return;
        }
        MemberColumnFilterDescriptor desc = clubsGrid.FilterDescriptors[clubsGrid.FilterDescriptors.Count - 1] as MemberColumnFilterDescriptor;
        filteredText.Text += desc.Member + " ";
    }

    How does this work for you?

    Regards,
    Dimitrina
    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.

     
  5. Dongzhi
    Dongzhi avatar
    25 posts
    Member since:
    Jan 2014

    Posted 08 Oct 2014 in reply to Dimitrina Link to this post

    Yes this worked for however I made a few minor changes so I wouldn't get redundant filter names when the user filters the same column using the checkboxes.

    var finaldesc = grid.FilterDescriptors;
    this.filterRecordText.Text = string.Empty;

                if (grid.FilterDescriptors.Count != 0)
                {
                    foreach (var filterMember in finaldesc)
                    {
                        var desc = filterMember as MemberColumnFilterDescriptor;
                        this.filterRecordText.Text += desc.Member + " ";
                    }
                }
Back to Top