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

Display Filtered Records

4 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dongzhi
Top achievements
Rank 1
Dongzhi asked on 01 Oct 2014, 06:25 PM
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;
        }

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 06 Oct 2014, 11:09 AM
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.
 
0
Dongzhi
Top achievements
Rank 1
answered on 07 Oct 2014, 07:08 PM
I don't know how loop through the FilterDescriptors collection for the filtered column names and display them to the user.
0
Accepted
Dimitrina
Telerik team
answered on 08 Oct 2014, 07:41 AM
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.

 
0
Dongzhi
Top achievements
Rank 1
answered on 08 Oct 2014, 09:07 PM
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 + " ";
                }
            }
Tags
GridView
Asked by
Dongzhi
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Dongzhi
Top achievements
Rank 1
Share this question
or