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

Clear CheckList Filtering

5 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chaim
Top achievements
Rank 1
Chaim asked on 27 Jan 2014, 06:27 PM
Hi

I was looking at this: http://www.telerik.com/help/aspnet-ajax/grid-filtering-multi-select-filtering.html
and this: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

But I wanted to create a "Clear Filters" button, the second link gives an example... and it works... more or less..
It clears all the filters, but the Checklist keeps its old values, so whenever I choose a new filter after clearing... the grid will apply the old filters (since the checklists are still checked)

Is there a way to revert the checklist to its original state??? (in this case to "(Select All)"

Thanks!

5 Answers, 1 is accepted

Sort by
0
Chaim
Top achievements
Rank 1
answered on 27 Jan 2014, 06:35 PM
Adding "column.CurrentFilterFunction = GridKnownFunction.NoFilter;"
won't filter next time using those filters... but this happens

1: Filter by checkin 2 checkboxes in column A
2: Grid is filtered
3: Clear Filters
4: Grid returns all rows unfiltered
5: Open again filter for columns A
6: Those 2 checkboxes from step 1 are still checked
7: Filter by Columns B
8: Grid is filtered ONLY by column B (Even though checkboxes for column A were checked (with NoFilter))
9: Open filters for columna A
10: (Select All) is selected

so it seems that when a NoFilter is applied, it should select "Select All" but since I'm doing it from codeBehind, it doesn't happen until the rebind from selecting another filter

0
Kostadin
Telerik team
answered on 30 Jan 2014, 12:53 PM
Hello Oscar,

Thank you for contacting us.

You could use a EvaluateFilterExpression() method and pass the GridFilteringItem in order to clear the filter. Please check out the following code snippet.
protected void Button1_Click(object sender, EventArgs e)
{
    RadGrid2.MasterTableView.FilterExpression = string.Empty;
    foreach (GridColumn column in RadGrid2.MasterTableView.RenderColumns)
    {
        if (column is GridBoundColumn)
        {
            GridBoundColumn boundColumn = column as GridBoundColumn;
            GridFilteringItem filter = RadGrid2.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
            boundColumn.EvaluateFilterExpression(filter);
        }
    }
    RadGrid2.Rebind();
}

Regards,
Kostadin
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Chaim
Top achievements
Rank 1
answered on 31 Jan 2014, 10:25 PM
Hi Kostadin

I tried your suggestion... but I think it didn't work... here is my code (after your suggestion) (I use GridColumn because I also want to reset FilterTemplates)

protected void LimpiarFiltros()
    {
        rgDiscrepancias.MasterTableView.FilterExpression = string.Empty;
 
        foreach (GridColumn columna in rgDiscrepancias.MasterTableView.RenderColumns)
        {
            GridFilteringItem filter = rgDiscrepancias.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
            columna.EvaluateFilterExpression(filter);
        }
 
        rgDiscrepancias.Rebind();
    }

Now... When I filter, I get the expected result
When I Clean Filters, I get the expected grid contents... but not what I would expect on the filters section

The first attached file is how the filters look
1. Before I apply filters
2. ------
3. After filters have been cleared
0
Chaim
Top achievements
Rank 1
answered on 31 Jan 2014, 10:28 PM
(I can't find an edit option....)

Sorry, clicked post too early...


so the filters are applied and cleared correctly, but the checklist status is kept as I left it when filtering...

After clearing the filters I would expect the checklist to return to its initial unfiltered status where all options are selected (to match the content of the grid since it isn't filtered anymore)


Thank you.
0
Kostadin
Telerik team
answered on 05 Feb 2014, 01:54 PM
Hello Oscar,

I prepared a small sample and attached it to this thread. Please give it a try and let me know about the result.

Regards,
Kostadin
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Chaim
Top achievements
Rank 1
Answers by
Chaim
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or