When trying to filter on a string with square brackets [ ] in it the filter does not work (all rows are still shown). I am assuming that this is a situation that grid filtering can't handle. Is there a solution for this issue or at least a list of invalid characters for filtering that I can pass along to our testers.
Thanks
John
Thanks
John
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2009, 12:12 PM
Hello,
Here is a work around on how to implement filtering when special characters such as '[' or ']' are entered:
c#:
Hope this helps...
Princy.
Here is a work around on how to implement filtering when special characters such as '[' or ']' are entered:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
RadGrid1.MasterTableView.FilterExpression = ""; |
GridFilteringItem filterItem = (GridFilteringItem)RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; |
TextBox txtFilter = (TextBox)filterItem["EmployeeID"].Controls[0]; |
string searchFor = txtFilter.Text; |
if (searchFor.Contains("[") || searchFor.Contains("]")) |
{ |
Char[] oChars = searchFor.ToCharArray(); |
StringBuilder oStringBuilder = new StringBuilder(); |
for (int i = 0; i < oChars.Length; i++) |
{ |
Char theChar = oChars[i]; |
switch (theChar) |
{ |
case '[': |
case ']': |
oStringBuilder.Append(string.Format("", theChar)); |
break; |
default: |
oStringBuilder.Append(theChar); |
break; |
} |
} |
searchFor = oStringBuilder.ToString(); |
RadGrid1.MasterTableView.FilterExpression = "([EmployeeID] = "+ searchFor+") "; //alter the filter function based on CurrentFilterFunction selected |
RadGrid1.MasterTableView.Rebind(); |
} |
} |
Hope this helps...
Princy.
0
Adam
Top achievements
Rank 1
answered on 20 Jan 2010, 06:22 PM
The originator of this thread is on my team and we're coming back to this issue to some extent. Perhaps Princy understood the intent of the post, and perhaps not, but just to make sure:
The main issue here is that our grid data often includes characters like single quotes, double quotes, or square brackets, and when attempting to filter on these values, it appears as though the grid does not recognize that the strings match up, which it needs to. The filtering isn't throwing any errors per se, so it's not so much our needing to remove the characters beforehand, the users would just prefer to actually be able to support all characters.
So, if this type of functionality is not currently implemented or is a technical limitation with the RadGrid control, we'd like to know, and if available, we'd like a list of characters that cannot be supported by grid filtering.
Thanks,
Adam.g
0
Hi Adam,
Could you please try setting the EnableLinqExpressions property of the problematic grid to false and see if it makes any difference?
In the meanwhile I will check out if there are signs that should be omitted in the grid filter values.
Looking forward your reply,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Could you please try setting the EnableLinqExpressions property of the problematic grid to false and see if it makes any difference?
In the meanwhile I will check out if there are signs that should be omitted in the grid filter values.
Looking forward your reply,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Adam
Top achievements
Rank 1
answered on 25 Jan 2010, 10:29 PM
Sorry, I suppose it wasn't clear that we're using the .Net 2.0 build of RadGrid, not 3.5. So all of the grid filtering is presumably done internally to the RadGrid, i.e. we're not doing any client binding or server-side filtering with the grid. Also, hence, no EnableLinqExpressions property on the 2.0 build either.
0
Hi Adam,
Here is a list of the illegal characters and strings that should not be used in the grid filter values:
I hope this helps.
Best wishes,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Here is a list of the illegal characters and strings that should not be used in the grid filter values:
" LIKE ", " AND ", " OR ", "\"", ">", "<", "<>", " NULL ", " IS "
In order to exclude the " sign from the list, try adding the follwin code to the page with the gid:protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
GridFilterFunction.IllegalStrings =
new
string
[] {
" LIKE "
,
" AND "
,
" OR "
,
">"
,
"<"
,
"<>"
,
" NULL "
,
" IS "
};
}
I hope this helps.
Best wishes,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kevin
Top achievements
Rank 1
answered on 26 Apr 2017, 02:57 AM
Hi team,
We are having a similar issue to this with RadGrid column filtering.
We want to be able to filter a string of text like "Don't". We assume it is because of the special character '
I tried to use the above examples but no luck.