Clear filter expresssion text box in radgrid

4 posts, 0 answers
  1. Shweta
    Shweta avatar
    2 posts
    Member since:
    Sep 2011

    Posted 03 Oct 2011 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Oct 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pramod
    Pramod  avatar
    2 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to Princy Link to this post

    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>
  5. Pramod
    Pramod  avatar
    2 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to Pramod Link to this post

    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;
                        }
                    }
                }
            }
Back to Top