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

How to filter radgrid with autocomplete textbox

4 Answers 556 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Berkant Oral
Top achievements
Rank 1
Berkant Oral asked on 07 Nov 2012, 10:45 AM
Hi everyone, 
I want to filter grid with by textbox. This textbox has got property autocomplete. I want to run this code in textbox onchange method. I write this code but I always need press for filter the grid. How can I fix this

<telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True"
    EnableTheming="True">
</telerik:RadScriptManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound"
    OnNeedDataSource="RadGrid1_NeedDataSource" AllowPaging="true" AllowFilteringByColumn="true"
    EnableLinqExpressions="false">
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" EditMode="InPlace">
        <CommandItemSettings ShowExportToPdfButton="true" />
        <Columns>
            <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn UniqueName="Name" DataField="Name">
                <FilterTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"  OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
                </FilterTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridEditCommandColumn>
            </telerik:GridEditCommandColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>


protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
       {
           dynamic data = new[] {
            new { ID = 1, Name ="aaa"},
            new { ID = 2, Name = "bbb"},
            new { ID = 3, Name = "ccc"},
            new { ID = 4, Name = "ddd"},
             new { ID = 5, Name ="eee"}
          };
           RadGrid1.DataSource = data;
       }
 
       protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
       {
 
       }
 
       protected void TextBox1_TextChanged(object sender, EventArgs e)
       {
           TextBox TextBox1 = sender as TextBox;
           RadGrid1.MasterTableView.FilterExpression = "([Name] LIKE \'%" + TextBox1.Text.Trim() + "%\') ";
           GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Name");
           column.CurrentFilterFunction = GridKnownFunction.Contains;
           column.CurrentFilterValue = TextBox1.Text.Trim();
 
           RadGrid1.Rebind();
 
       }


Best Regards

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 12 Nov 2012, 02:58 PM
Hi,

To run the code inside TextChanged event you should move the focus from the input as shown in this video. Give it a try and let me know if other questions arise.

Greetings,
Pavlina
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
Lobna
Top achievements
Rank 1
answered on 30 Jan 2013, 12:28 PM
Can I make something as in this link 
Google Filtering

but the grid has GridBoundColumn not creating columns during run time?

Is it possible?

Thanks,
0
Pavlina
Telerik team
answered on 04 Feb 2013, 01:26 PM
Hello,

You could achieve your goal, by using FilterTemplate with RadAutoCompleteBox and use the logic from google like filtering demo. Here you could find demo and here is the online documentation about FilterTemplate.

All the best,
Pavlina
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
bharath
Top achievements
Rank 1
answered on 08 Sep 2014, 11:12 PM
my requirement is add textbox to radgrid columns and that text box should act as auto complete extender.
My radgrid and textbox are dynamic..so i don't know which column  having textbox and bind that textbox to autocomplete extender at design time.

   provide some example to do this.

/Tahnks
Bharath
Tags
Grid
Asked by
Berkant Oral
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Lobna
Top achievements
Rank 1
bharath
Top achievements
Rank 1
Share this question
or