Clear all filters button

5 posts, 0 answers
  1. ColinBlakey
    ColinBlakey avatar
    21 posts
    Member since:
    Aug 2006

    Posted 14 Jun 2013 Link to this post

    I have a complex RadGrid with many columns and filters on all the columns. As the use can end up with a complex set of filter I want to add a 'clear all filters' button. As it is a parent/detail grid I figured I would use the space next to the filters created by the expand/collapse column. So I managed to 'successfully' put a new image button in that space with the following code which I have in my Grid ItemDataBound method..

    // Creating filtering row clear all filters button
    if ((e.Item.ItemType == GridItemType.FilteringItem))
        var clearFilterButton = new RadButton
            ButtonType = RadButtonType.StandardButton,
            Height = 22,
            Width = 22
        clearFilterButton.Image.EnableImageButton = true;
        clearFilterButton.Image.ImageUrl = string.Format("../App_Themes/{0}/Images/ClearFilter.png", Page.Theme);
        clearFilterButton.ToolTip = "Clear current filter(s)";
        clearFilterButton.Click += ClearButton_Click;
        var expandCollapseColumn = (GridTableCell) e.Item.Controls[0];

    I'm assuming I have this all wrong as I have two problems.
    1) Clicking the button makes it disappear
    2) Clicking the button never fires the clearbutton event.

    Can anyone help and maybe this should be a feature in the RadGrid control in the future?


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2013 Link to this post


    I guess you want to clear the filter textbox values on a button click.Please try this code on the button click event.

    protected void FilterButtonClear_Click(object sender, EventArgs e)
        foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
             column.CurrentFilterFunction = GridKnownFunction.NoFilter;
             column.CurrentFilterValue = string.Empty;
         RadGrid1.MasterTableView.FilterExpression = string.Empty;

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ColinBlakey
    ColinBlakey avatar
    21 posts
    Member since:
    Aug 2006

    Posted 17 Jun 2013 Link to this post


    I've already seen this demo and one or two others and have code which works from a separate button (ala the demo) and also a command bar button. What I'm trying to achieve is adding the button next to the filters in the empty space created by the expand./collapse column.

    <telerik:RadGrid ID="viewStatusRadGrid" EnableHierarchyExpandAll="true" ...
        <!-- Add expand/collapse column -- Adds space for clear filter button
        <ClientSettings AllowExpandCollapse="True" />
        <MasterTableView DataKeyNames="ID" TableLayout="Auto" AllowNaturalSort="false">
            <telerik:GridBoundColumn ..../>
        <Scrolling AllowScroll="false" />


  5. Kostadin
    Kostadin avatar
    1711 posts

    Posted 19 Jun 2013 Link to this post

    Hi Colin,

    I prepared a small sample based on your scenario and attached it to this thread. As you could see the button click event is being fired and the filter is cleared properly. Could you please give it a try and let me know how it differs from your real setup.

    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 the blog feed now.
  6. ColinBlakey
    ColinBlakey avatar
    21 posts
    Member since:
    Aug 2006

    Posted 20 Jun 2013 Link to this post

    This is where it's a pain. I agree that the sample code works fine but when I have this code in my current application it does not work. This would suggest that something else is causing this to fail. Time for some trial and error testing to figure out the cause.


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017