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

Show Filter Popup

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 04 Dec 2009, 02:19 PM
I would like to be able to have the filter popup for a particular column from an outside source.  I also want to be able to track which columns are currently being filtered.  Basically what I have is a list of all the columns will be shown to the user and I will tell them whether that column has a filter or not, allow them to delete that filter and also allow them to add a filter to that column.  Is it possible to open the filter window from another source?  How can I track which columns currently are being filtered?

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Dec 2009, 01:07 PM
Hello Scott Rakestraw,

If you want to populate the filtering UI with your own distinct values you should attach to the DistinctValuesLoading event of the grid and fill the values that you want to appear in the list-box. In case that is not what you want, please elaborate.

When the filtering UI of a column filters the grid, it adds an object of type ColumnFilterDescriptor to the FilterDescriptors collection of the grid. To find out whether the grid is filtered by a certain column you should search in its FilterDescriptors collection for a ColumnFilterDescriptor associated with this column. Something like this:

IColumnFilterDescriptor existing =
    column.DataControl.FilterDescriptors.OfType<IColumnFilterDescriptor>()
    .Where(cfd => cfd.Column == column).FirstOrDefault();

If you find something (existing != null), then the grid is filtered by the column. To learn more about the ColumnFilterDescriptor please read my blog post "Pre-filtering RadGridView for Silverlight".

If you want to delete the filter for a given column then try to find it with the above code and if it exists remove it from the FilterDescriptors collection of the grid.

To add a filter programmatically simply configure one such ColumnFilterDescriptor as I have described in the above-mentioned blog post and then add it to the FilterDescriptors collection of the grid.

You cannot open the built-in filtering UI from another source, even though I am not sure what you mean by "another source". You can create your own custom filtering control to display in place of the built-in one by following the instructions in the step-by-step tutorial Custom Filtering with RadGridView for Silverlight.

To track which columns are being filtered, find all IColumnFilterDescriptor's in the FilterDescriptors collection and read their Column property. These are the columns that are currently filtered in some way.

Please, not that you will have to upgrade to our Latest Internal Build version in order to be able to do these things.

I hope this helps.

Regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or