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

Clear filter expresssion text box in radgrid

3 Answers 667 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Shweta
Top achievements
Rank 1
Shweta asked on 03 Oct 2011, 07:27 AM
I m using the filter option in radgrid to filter some data on basis of the option selected in dropedown menu. Now on changing the dropdown value and clicking on submit button, my filter expression test is still there and the data gets filtered. How do I remove the filter in the text box.
Please help!
Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Oct 2011, 07:00 AM
Hello Shweta,

Method1:
A more general and better approach is as follows
C#:
RadGridEvents.MasterTableView.FilterExpression = string.Empty;
foreach (GridColumn column in RadGridEvents.MasterTableView.RenderColumns)
{
    if (column.SupportsFiltering())
    {
        column.CurrentFilterValue = string.Empty;
    column.CurrentFilterFunction = GridKnownFunction.NoFilter;
   
    }
}
RadGridEvents.MasterTableView.Rebind();
Method2:
Try the following code snippet to clear the filters by a Buttonclick.
C#:
protected void Button1_Click(object sender, EventArgs e)
 
    RadGrid1.MasterTableView.FilterExpression = string.Empty;
    RadGrid1.MasterTableView.Rebind();
 }

Thanks,
Princy.
0
Pramod
Top achievements
Rank 1
answered on 06 Mar 2015, 05:57 PM
Hi Princy,

In my case there is a <MasterTableView> <DetailTables> within the RadGrid. Both Master and Detail tables have filtering enabled and it works perfectly fine. When I try to remove the filterexpression at the DetailTable level (using the 'nofilter') menu option, the filter expression still persists in the textbox. How can I remove this? What code can I write to identity if the filtering request happened from mastertable or detailtable? In the end, I just want the text from the filter textbox to disappear.

Sample code:

<telerik:RadGrid ID="SomeGridView" runat="server">
...
<ClientSettings>
    <ClientEvents OnFilterMenuShowing="FilterMenuShowing" />
</ClientSettings>
...
<Columns> ... </Columns>
...
<DetailTables>
    <telerik:GridTableView Name="Details">
        <Columns>
            <telerik:GridBoundColumn DataField="FieldName" HeaderText="Some Header" SortExpression="FieldName" UniqueName="FieldName" />
...
        </Columns>
    </telerik:GridTableView>
</DetailTables>
</telerik:RadGrid>
0
Pramod
Top achievements
Rank 1
answered on 06 Mar 2015, 06:47 PM
I think I resolved my own question.
But I find this extra effort was not needed for the MasterTableView filters, since it automatically cleared the textbox values when I selected "NoFilter".
Is this a known Telerik bug?
Is it fixed in the latest version? My version is 2015.1.225.45


        protected void RadGridView_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = e.DetailTableView.ParentItem;

            if (IsPostBack == true)
            {
                foreach (GridColumn thisColumn in e.DetailTableView.Columns)
                {
                    if (thisColumn.CurrentFilterFunction == GridKnownFunction.NoFilter)
                    {
                        thisColumn.CurrentFilterValue = string.Empty;
                    }
                }
            }
        }
Tags
Filter
Asked by
Shweta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pramod
Top achievements
Rank 1
Share this question
or