RadControls for ASP.NET AJAX
You can use the "Custom" filter function to introduce a filter function that is not included in the default list, or to allow multiple columns with the same data type to have different filtering menus.
The RadGrid filtering menu is implemented using a single object server-side, which is cloned for the separate column menus that appear client-side. This implementation speeds up grid performance, but means that every column of the same data type displays the same list of available filter functions.
Suppose you want to remove a filtering option from the menu of a column while leaving it available in the menu of another column that has the same data type. You can accomplish this in the following way:
Add a handler for the Init event of the grid. In the Init event handler,
Remove the filtering function from the FilterMenu of the grid. This removes it from the menu of all the columns in the grid.
Change the menu item for the "Custom" filtering function so that its text is the name of the filtering function you removed.
On any column that should allow the removed filtering function, set the FilterListOptions property to VaryByDataTypeAllowCustom. This adds a "Custom" option (which now looks like the removed filtering function) to the end of the filter menu for that column.
Add a handler for the ItemCommand event of the grid. In the ItemCommand event handler,
Identify commands from the filter menu by checking that the value of e.CommandName is RadGrid.FilterCommandName.
The value of e.CommandArgument is a Pair object that contains the name of the filtering function and the UniqueName of the column.
When the filtering function is "Custom", change it to the name of the filtering function you removed.
As an alternate approach, when the filtering function is "Custom", you can
Set e.Canceled to True to cancel the default filtering.
Set the FilterExpression property of the table that contains the column to a valid filter expression. Be sure to honor any existing filter expression that is already set.
Rebind the grid to apply the filter expression.
Example 1: Changing the filter function name
Example2: Replacing the filter expression
For this example, you can use the same ASPX file and Init handler as the last example. Only the ItemCommand handler is different. In the example that follows, the grid behaves the same way as in the previous example. However, this approach is more extendable, as you can introduce any valid filter expression, not just mimic the behavior of one of the built-in choices.
With the .NET 3.5 build of RadGrid for ASP.NET AJAX and LINQ filter expressions enabled (EnableLinqExpressions = true), the filter expressions set for the grid either internally by its filtering mechanism or manually in code should conform to the LINQ expression syntax instead of the old T-SQL syntax. Only thus they will be evaluated properly by the control.