Hi Randall,
Essentially, I have based my code on info from the following links:
http://www.telerik.com/help/aspnet/grid/grdimplementingfilteringfortemplatecolumns.html
http://www.screencast.com/users/mira_/folders/Jing/media/85f2e1fe-1029-4d3f-a881-7afe68c5e23f
I must add that I'm not doing the following:
1. I'm not handling the ItemClick event for the filter menu item (because it doesn't consistently fire for some reason)
2. I'm also not handling the ItemCommand event of the RadGrid because it seems to me that when this event is fired (when using template columns), only the original filter selection (prior to the postback) is available and not the new selection.
3. Another note - I've found that handling events like the OnTextChanged for a textbox in the filtering item cell tends to mess things up a little (in terms of when the selected filter function becomes available). If things don't seem to be working, it may be an idea to disable these event handlers and see if it makes a difference.
In the EvaluateFIlterExpression method, you simply create your custom filter expression and return it. Sample code below:
public
override string EvaluateFilterExpression(GridFilteringItem filteringItem)
{
string filter = string.Empty;
TableCell cell = filteringItem[this.UniqueName];
TextBox tbPattern = cell.Controls[0] as TextBox;
if (tbPattern.Text != string.Empty)
{
if (this.CurrentFilterFunction == GridKnownFunction.Custom)
{
filter =
//Create your filter expression for the Custom filter
}
else
{
filter =
//Create your filter expression for the other known filters
}
}
else
{
filter =
string.Empty;
}
return filter;
}
Hope that helps.
Arif