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

filter not works when i use words "AND", "OR" in filter expression

3 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Igor Ashmetkov
Top achievements
Rank 1
Igor Ashmetkov asked on 13 Oct 2011, 09:17 AM
     Hello.
I`m using RadGrid with SqlDataSource. Filter in RadGrid work fine except using such words as "AND", "OR" in filter expression (for example "mike and smith"). In this situation filter is reseting and grid not filtered.
I didn`t find any post with this question.
Any ideas?

3 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 13 Oct 2011, 04:21 PM
is all the filtering done in code?  this snippet works but filtering on the page is disabled
private string AppendFilterExpression(string filterExpression)
{
    StringBuilder sb;
    sb = new StringBuilder(rgEditOrder.MasterTableView.FilterExpression);
    if (filterExpression == string.Empty)
        return sb.ToString();
    if (sb.ToString() != string.Empty)
    {
        sb.Append(" AND ");
    }
    sb.Append(filterExpression);
    return sb.ToString();
}
the syntax is [UniqueName] = value
0
Mira
Telerik team
answered on 17 Oct 2011, 09:46 AM
Hello Marianne,

The AND and OR words (with capital letters) are reserved words for the Telerik RadGrid and cannot be used in the filter values.
However, when using for example "mike and smith" (and with small letters), the grid will interpret it as a valid string and filter for it as you can see in this demo.

I hope this helps.

Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Elliott
Top achievements
Rank 2
answered on 17 Oct 2011, 08:37 PM
I misunderstood the question - but Mira cleared up my confusion (and answered Igor's question in the process)
Tags
Grid
Asked by
Igor Ashmetkov
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Mira
Telerik team
Share this question
or