I am setting up a dummy grid with data to explain my requirement.
ColumnA ColumnB ColumnC
------------ ------------- -------------
a b c
a e f
g h i
Suppose, column A and B are filtered with default text box and funnel. Column C has drop down list for filtering. Filtering column C gives the proper filtered row, but on selecting no filter in dropr down list, the previous filters are not remembered and entire data is displayed.
Suppose I filter Column A with value 'a' and filter criteria 'Equal To'. It will give 2 rows:
ColumnA ColumnB ColumnC
------------ ------------- -------------
a b c
a e f
Now if I filter Column C with drop down list by selecting 'c' it will give 1 row:
ColumnA ColumnB ColumnC
------------ ------------- -------------
a b c
Now if I select 'No Filter' in the Column C drop down , it gives all 3 rows as the initial grid, but I want the grid with last filter applied i.e:
ColumnA ColumnB ColumnC
------------ ------------- -------------
a b c
a e f
My code in the customdropdown list class that extends the GridTemplateColumn class where actual filtering is fired:
protected
void list_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlFilter = sender as DropDownList;
if (ddlFilter.SelectedIndex == 0) //My 'No Filter' option is at the top of the list
{
//First index is no filter. we need to clear all filters here.
RadGrid ragpeopleManagement = (RadGrid)((DropDownList)sender).Parent.Parent.Parent.Parent.Parent.Parent;
foreach (GridColumn column in ragpeopleManagement.MasterTableView.Columns)
{
column.CurrentFilterFunction =
GridKnownFunction.NoFilter;
column.CurrentFilterValue =
String.Empty;
}
ragpeopleManagement.MasterTableView.FilterExpression =
String.Empty;
ragpeopleManagement.MasterTableView.Rebind();
}
else
{
//GridFilteringItem filterItem = ((DropDownList)(sender)).NamingContainer as GridFilteringItem;
GridFilteringItem filterItem = (GridFilteringItem)((DropDownList)(sender)).NamingContainer;
filterItem.FireCommandEvent(
"Filter", new Pair("EqualTo", this.UniqueName));
}
}
Pls advice how to retain the previous filters in the grid even after selecting 'No Filter' in the drop down list filter column.