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

[Solved] Clearing Filter

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen Altemus
Top achievements
Rank 1
Stephen Altemus asked on 05 Feb 2010, 05:51 PM
I been trying to clear the filter through code behind methods.

I set each columns to

column.CurrentFilterFunction =

GridKnownFunction.NoFilter;

Then I rebind the grid

The grid then refreshes but all the records are missing.  I would have expected the grid to show all records...

So how do I programatically clear the filter in code behind c# and have the grids show all records.


I am just frustrated I missed something and google this time has failed me.

Thanks in advance

Stephen Altemus

2 Answers, 1 is accepted

Sort by
0
Stephen Altemus
Top achievements
Rank 1
answered on 05 Feb 2010, 07:43 PM
Found an example in the demo code provided thought I would share

Code is from the Telerik online demo I did not create it myself just took me some time to find the right example.


RadGridEvents.MasterTableView.FilterExpression =

string.Empty;

 

 

foreach (GridColumn column in RadGridEvents.MasterTableView.RenderColumns)

 

{

 

    if (column is GridBoundColumn)

 

    {

 

        GridBoundColumn boundColumn = column as GridBoundColumn;

 

        boundColumn.CurrentFilterValue =

string.Empty;

 

    }

}

 

 

RadGridEvents.MasterTableView.Rebind();

0
Tsvetoslav
Telerik team
answered on 08 Feb 2010, 02:53 PM
Hello Stephen,

A more general and better approach is as follows:

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();

Best wishes,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Stephen Altemus
Top achievements
Rank 1
Answers by
Stephen Altemus
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or