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

Filter button outside of grid

3 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AereoN
Top achievements
Rank 1
AereoN asked on 23 Nov 2009, 04:43 AM
I have a grid with custom radtextbox for in the filter template.
Instead of the filter button that usually is found in the grid, I want to place my filter button outside of the grid.
Can someone show me how do I achieve this?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 23 Nov 2009, 07:53 AM
Hello AereoN, 

Check out the following code and see if helps achieve your scenario:
aspx:
<asp:Button ID="Button1" runat="server" Text="Filter" OnClick="Button1_Click" />  
.....  
  
<telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" UniqueName="ProductName">                          
       <FilterTemplate>   
            <telerik:RadTextBox ID="RadTextBox1" runat="server" ></telerik:RadTextBox>   
       </FilterTemplate>   
</telerik:GridBoundColumn>   
...  

c#:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        GridFilteringItem filter = (GridFilteringItem)RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; 
        RadTextBox txtbx = (RadTextBox)filter["ProductName"].FindControl("RadTextBox1");       
        RadGrid1.MasterTableView.FilterExpression = "([ProductName] LIKE \'%"+txtbx.Text+"%\')"
        GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("ProductName"); 
        column.CurrentFilterFunction = GridKnownFunction.Contains; 
        column.CurrentFilterValue = txtbx.Text; 
        RadGrid1.MasterTableView.Rebind(); 
    } 

Hope this helps..
Princy.
0
AereoN
Top achievements
Rank 1
answered on 24 Nov 2009, 04:48 AM
Thanks for the reply, Princy.

Actually I tried several methods already and I'm always stuck  at the Grid rebinding issue where this error will always occur.
ParseException was unhandled by user code: Expression expected.

This error even occur using your example.
Any help please?
0
AereoN
Top achievements
Rank 1
answered on 24 Nov 2009, 07:56 AM
Found the problem.
Need to set enablelinqexpressions to false.
Thanks again.
Tags
Grid
Asked by
AereoN
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
AereoN
Top achievements
Rank 1
Share this question
or