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

Custom FilterMenu by Column (server-side)

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
End
Top achievements
Rank 1
End asked on 27 Apr 2015, 12:07 PM

Hello,
 I'm trying to customize the filter menu of my RadGrid based on the column.  The server-side demo only shows how to change the filter menu for every column, not by column.  Is there any way to this with the current API?  Here is the code I’ve being working with to implement this functionality.  This code removes "Contains" from all the filtermenus.  I would like to do this for a specific column.

protected void RadGrid1_Init(object sender, System.EventArgs e)
{
     foreach(GridColumn column in RadGrid1.Columns)
    {
        if (column.HeaderText == "ColumnName")
        {
            GridFilterMenu menu = RadGrid1.FilterMenu;

            menu.Items.RemoveAt(menu.Items.FindItemByText("Contains").Index);
        }
    }
}

 

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 28 Apr 2015, 08:10 AM
Hi,

To achieve your scenario you could follow the JavaScript approach shown in the article linked below:
http://www.telerik.com/help/aspnet-ajax/grid-reducing-filtermenu-options.html

The idea is to subscribe to RadGrid FilterMenuShowing event and change the options dynamically. Note that a client-side JavaScript approach is required because the filter options are changed on the client and there is no way to customize the menu based on each column from the server because the changes will be overridden from the client:

You should be able to adjust the code to check for the name of the column instead of its data type, if needed.

Regards,
Pavlina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
End
Top achievements
Rank 1
answered on 28 Apr 2015, 02:38 PM
Thanks Pavlina.  I will try client side.
Tags
Grid
Asked by
End
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
End
Top achievements
Rank 1
Share this question
or