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

[Solved] CurrentFilterFunction/Value and Session variable

1 Answer 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 Feb 2010, 12:51 PM
I have a grid and I'd like to always apply two filter conditions it whenever the user filters the grid.
1) always filter a column based on a bool being false
2) always filter a column based on the value of a session variable

I can get 1) working easy enough with the following code
<telerik:GridCheckBoxColumn DataField="IsOptimumStaff"  
  HeaderText="Active" CurrentFilterFunction="EqualTo" 
  CurrentFilterValue="false" Visible="false" /> 

But I can't get 2) to work I've tried

<telerik:GridBoundColumn DataField="Region.RegionId"  
  HeaderText="Region Id" Visible="false"  
  CurrentFilterFunction="EqualTo"  
  CurrentFilterValue='<%= Session("CurrentRegion") %>' /> 

Is it even possible to do with markup or do I need to write some code behind? If so how do I have my own default filter items while preserving the users filter?

Thanks 
Chris

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 23 Feb 2010, 12:24 PM
Hello Chris,

You need to set the filter function/value properties of the column in code behind:

protected override void Page_Load(EventArgs e)
{
    base.OnLoad(e);
 
    RadGrid1.MasterTableView.GetColumnSafe("CurrentRegion").CurrentFilterFunction = GridKnownFunction.EqualTo;
    RadGrid1.MasterTableView.GetColumnSafe("CurrentRegion").CurrentFilterValue = Session["CurrentRegion"].ToString();
}

The above code lines assume that  you should set "CurrentRegion" for the UniqueName property of the column.

I hope this helps.

Greetings,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or