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

[Solved] Perform filter after 3 chars typed

2 Answers 220 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 25 May 2009, 09:21 AM
Hi!

Is it possible to make the radgrid perform automatic filtering after the user has typed 3 (or more) characters in the filer box?

If so, whats the best approach?
Is there a example ot this somewhere that I have missed :) ?

Regards
Per Bornsjö

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 26 May 2009, 12:55 PM
Hi Per,

You can use the following example as a starting point. Essentially, you can have a filter texbox with onkeypress client side handler attached. When the user has entered 3 characters, you can fire the filter command.
I hope this suggestion gets you started properly.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Princy
Top achievements
Rank 2
answered on 27 May 2009, 12:01 PM
Hello,

You can try out the following code to achieve the required scenario:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    {    
        if (e.Item is GridFilteringItem) 
        { 
            GridFilteringItem filterItem = (GridFilteringItem)e.Item; 
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
            { 
                if ((col.UniqueName != "ExpandColumn") && (col.UniqueName != "RowIndicator")) 
                { 
                     
                    TextBox filtertxt = (TextBox)filterItem[col.UniqueName].Controls[0];                     
                    { 
                        filtertxt.Attributes.Add("onkeyup", "Filter('" + col.UniqueName + "','" + filtertxt.ClientID + "')"); 
                    } 
 
                } 
            } 
        } 
    } 

js:
function Filter(colName,filtertxt) 
    {       
       var filterTxt = document.getElementById(filtertxt); 
       var MasterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
       if(filterTxt.value.length>2) 
       { 
        
           MasterTable.filter(colName, filterTxt.value, Telerik.Web.UI.GridFilterFunction.StartsWith);    
               
       } 

Thanks
Princy.
Tags
Grid
Asked by
Per
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Princy
Top achievements
Rank 2
Share this question
or