I was trying to customize a filter so that it'll filter the grid according to a predefined string. I was looking for a way to work around the issue of filtering a string that contains special characters.
basically, if the user select a filter with a name of "greater"...then it'll return all items that has the value ">130hp"...otherwise, if a user select a filter with a name of "less"....then it'll return all items that has the value "<130hp"
the following contains my initial code...copied and modified from the telerik documentation. Any assistance is welcome.
protected
void GridChevronPortEQ_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
Pair filterPair = (Pair)e.CommandArgument;
if (filterPair.First.ToString() == "greater")
{
string colName = filterPair.Second.ToString();
TextBox tbPattern = (e.Item as GridFilteringItem)[colName].Controls[0] as TextBox;
string[] values = tbPattern.Text.Split(' ');
if (values.Length == 2)
{
e.Canceled =
true;
string newFilter = "(([" + filterPair.Second + "] >='" + values[0] + "') AND ([" + filterPair.Second + "] <='" + values[1] + "'))";
if (GridChevronPortEQ.MasterTableView.FilterExpression == "")
{
GridChevronPortEQ.MasterTableView.FilterExpression = newFilter;
}
else
{
GridChevronPortEQ.MasterTableView.FilterExpression =
"((" + GridChevronPortEQ.MasterTableView.FilterExpression + ") AND (" + newFilter + "))";
}
GridChevronPortEQ.Rebind();
}
}
}
}