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

[Solved] apply different filter options in databound RadGrid

3 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 30 Jun 2009, 08:45 AM
hi I have a databound RadGrid, I'd like to allow different options items for different types of columns. e.g. for string columns i only want to have "NoFilter" and "Contains" options, for number columns I only want to have "NoFilter", "GreaterThan" and "LessThan" options. I tried to apply the method (see below) under radgrid1_Init() and radgrid1_databound(), no luck with either way. please hlep

foreach (GridColumn gc in radgrid1.MasterTableView.RenderColumns)
            {
if (gc.DataType.ToString() == "string")
            {
                GridFilterMenu menu = rgQualificationList.FilterMenu;
                int i = 0;
                while (i < menu.Items.Count)
                {
                    if (menu.Items[i].Text == "NoFilter" ||
                        menu.Items[i].Text == "Contains" ||
                        menu.Items[i].Text == "EqualTo" ||
                        menu.Items[i].Text == "StartsWith")
                    {
                        i++;
                    }
                    else
                    {
                        menu.Items.RemoveAt(i);
                    }
                }
            }

if (gc.DataType.ToString() == "DateTime")
            {
................
............

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 02 Jul 2009, 03:28 PM
Hi sf,

Have you considered applying these different filter menu options on the client intercepting the OnFilterMenuShowing event of the grid? Review the first paragraph of this documentation topic which elaborates on this subject:

http://www.telerik.com/help/aspnet-ajax/grdreducingfiltermenuoptions.html

Thus you should be able to have different filtering menus based on the data type of the respective column in the grid source.

Regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sf
Top achievements
Rank 1
answered on 03 Jul 2009, 02:44 AM
thanks Sebastian for your help. After I implemented the exactly the same code my string type columns filter become disordered. A black dot appearred on the right side of option "StartWith", The filter dropdown becomes 2 columns, the 2nd column only contains "Contains" option which is on the same row as NoFilter, and "EndsWith" option which is on the same row as "StartWith".... the rest rows in 2nd column is empty...

any idea what is causing this problem?

I suspect it is this line that caused the problem:

item.get_element().className =

"hideFilterOption";

 

0
Sebastian
Telerik team
answered on 03 Jul 2009, 08:26 AM
Hello sf,

Indeed the purpose of this style is to apply a difference css class for the hidden menu items if you prefer in order to customize the layout of the filtering menu when items are removed. You can strip this className setting to see whether this helps.
 
Regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
sf
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
sf
Top achievements
Rank 1
Share this question
or