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

Grid Filter issue

2 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vairam
Top achievements
Rank 1
vairam asked on 19 Apr 2010, 04:31 PM
Hi

If i Type '|' this special character in the filter text box its giving me a error.

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx.

How can i restrict this

Regards
Vairamuthu




2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 20 Apr 2010, 05:43 AM

Hello,

RadGrid do not support filtering using some special characters. To be more specific, " LIKE ", " AND ", " OR ", " | ",  "\"", ">", "<", "<>", " NULL ", " IS " and '';" are unsupported.

I tried following approach in order to prevent the special characters entering in filer textbox.

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""CheckSpecial(this, event)");   
        }   
    }   
}  

JavaScript:

 
<script type="text/javascript">   
function CheckSpecial(text,e)   
{   
    var regx, flg;     
    regx = /[^0-9a-zA-Z'' ]/     
    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
vairam
Top achievements
Rank 1
answered on 20 Apr 2010, 05:48 AM
Hi shinu

Thanks i will try this.

Regards
Vairamuthu
Tags
Grid
Asked by
vairam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
vairam
Top achievements
Rank 1
Share this question
or