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

[Solved] Filtering Grid on ";" Character Causes Error

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 07 Oct 2009, 11:42 AM
Hello,

When entering a ";" character in the basic "contains" filter for a text column causes an "IndexOutOfRange" exception.
Below is the stack trace:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

We have been able to duplicate this issue on the RadGrid demo.
Is there a work around? Or, some way to remove this character from a user's filtering.

Thanks,
Jon

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Oct 2009, 11:57 AM
Hi Jon,

One suggestion would be preventing the entry of ; in filter textbox. Here is the code that I tried to accomplish this.

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

JavaScript:
 
<script type="text/javascript"
function CheckChar(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> 

-Shinu.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or