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

Attempting to set default filter on multiple columns

2 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 05 Apr 2014, 12:20 PM
There are multiple columns in the grid, two are checkbox columns.

I have one checkbox set to:
 CurrentFilterFunction="EqualTo" CurrentFilterValue="True"

and the other:
 CurrentFilterFunction="EqualTo" CurrentFilterValue="False"

EnableLinqExpressions is false.

The second filter is not applying: CurrentFilterValue="False".   I tried removing the first one, but the second one still did not apply.

Am I missing some syntax here?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Apr 2014, 03:18 AM
Hi Peter,

I guess you want to set Default Filter on Initial Load, please try the following code snippet.

ASPX:
<telerik:GridCheckBoxColumn DataField="IsTrue" HeaderText="IsTrue" UniqueName="IsTrue" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" CurrentFilterValue="True">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn DataField="IsActive" HeaderText="IsActive" UniqueName="IsActive" CurrentFilterFunction="EqualTo" CurrentFilterValue="False" AutoPostBackOnFilter="true">
</telerik:GridCheckBoxColumn>

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    RadGrid1.MasterTableView.FilterExpression = "([IsTrue] = 'True' AND [IsActive]='False') ";
    GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("IsTrue");
    column.CurrentFilterFunction = GridKnownFunction.EqualTo;
    column.CurrentFilterValue = "True";
    GridColumn column2 = RadGrid1.MasterTableView.GetColumnSafe("IsActive");
    column2.CurrentFilterFunction = GridKnownFunction.EqualTo;
    column2.CurrentFilterValue = "False";
    RadGrid1.MasterTableView.Rebind();
  }
}

Thanks,
Princy
0
Peter
Top achievements
Rank 1
answered on 07 Apr 2014, 12:08 PM
Thanks, that worked.   
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Peter
Top achievements
Rank 1
Share this question
or