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

RadGrid filtering with backslash

5 Answers 171 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nikoleta Ferdinandova
Top achievements
Rank 1
Nikoleta Ferdinandova asked on 21 Sep 2009, 09:45 PM
Hi,

I have a RadGrid bound server-side to a DataTable and in a RadAjaxManager and a filter on a GridBoundColumn with string values. 
The filter works fine except when I search for a backslash '\'. When escaped "\\" the filter works.
and it seems this filter doesn't work there either.
Is there a workaround this? 

Thank you
Nikoleta

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2009, 06:33 AM
Hi Nikoleta,

One workaround would be preventing the user to type ' \ ' in filter textbox. Try the following code in order to achieve this.

C#:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)   
{   
    if (e.Item is GridFilteringItem)   
    {   
        GridFilteringItem fItem = (GridFilteringItem)e.Item;   
        foreach (GridColumn col in RadGrid1.MasterTableView.Columns)   
        {   
            (fItem[col.UniqueName].Controls[0] as TextBox).Attributes.Add("onkeyup""Backslash(this, event)");   
        }   
    }   
}  

JavaScript:
 
<script type="text/javascript">  
function backslash(text,e)  
{  
  var regx, flg;    
    regx = /[/]/    
    flg = regx.test(text.value);    
    if (flg)  
    {    
        var val=text.value;  
        val=val.substr(0,(val.length)-1)  
        text.value=val;        
    }  
}  
</script>  

Hope this helps,
Shinu.
0
Nikoleta Ferdinandova
Top achievements
Rank 1
answered on 22 Sep 2009, 05:48 PM
Hi Shinu,

Thank you for your prompt reply.
I wasn't trying to ignore the backslash but to include it in the filter expression. I guess I can use the same approach to escape it. 
Is there any particular reason why the filter itself does not escape backslashes?
Nikoleta

0
Princy
Top achievements
Rank 2
answered on 23 Sep 2009, 06:55 AM
Hello Nikoleta Ferdinandova,

It seems that RadGrid does not support filtering using characters like "\", ">", "<", "<>"," LIKE ", " AND ", " OR ", " NULL ", " IS " and '';" . You can find this mentioned in the following forum link as well:
Semicolon ; in column filter generates error

Thanks
Princy.
0
NIRUBAMA
Top achievements
Rank 1
answered on 29 Aug 2012, 07:38 AM
Hi,

I have a RadGrid with radcomboBox inside it.I have allowfilteringcolumn set to true for the radcombobox.
When i try to filter using contains or any other filter operator, I am not getting the fully concatenated string of the Filterexpression.

Formula for Contains filter is as below:
 dataField LIKE '%value%'

I want to filter the concatenated string with "-" and the datafield.

That is if the Griditem.text is a value containing "BUM-Earth Mounding".
Here the Data field is Earth Mounding alone but it is concatenated with the griditem full text as "BUM-Earth Mounding".It shows no results as it is filtered by datafield formula as above alone.

But i want to get if i just give the "BUM", it should fetch the result.
Can anybody help me out. Also wild character "-" is not allowing to filter.Please tell me how to escape wild characters "-".
0
Andrey
Telerik team
answered on 03 Sep 2012, 08:53 AM
Hello,

In order to achieve your goal you could provide a filter expression for RadGrid manually and thus you will have full control on what value the filtering operations is performed on. More information about this approach could be found in this help topic.

All the best,
Andrey
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.
Tags
Grid
Asked by
Nikoleta Ferdinandova
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nikoleta Ferdinandova
Top achievements
Rank 1
Princy
Top achievements
Rank 2
NIRUBAMA
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or