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

[Solved] How to add filter option in a single column on custom field

1 Answer 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vivek tamboli
Top achievements
Rank 1
vivek tamboli asked on 08 Feb 2010, 02:18 PM

Hi
I am binding dataset to radgrid and i want to add filter option in a single column. Let me know how to do this.

-------------------------------------------------------

RadGrid1.DataSource = _DS.Tables[0];

RadGrid1.DataBind();

--------------------------------------------------


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Feb 2010, 01:02 PM
Hi,

You can use the grid's PreRender event to specify an initial filter using a specific column.

C#
protected void RadGrid1_PreRender(object sender, System.EventArgs e) 
 if (!Page.IsPostBack) 
 { 
   RadGrid1.MasterTableView.FilterExpression = "([Country] LIKE \'%Germany%\') "
   GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Country"); 
   column.CurrentFilterFunction = GridKnownFunction.Contains; 
   column.CurrentFilterValue = "Germany"
   RadGrid1.MasterTableView.Rebind(); 
 } 
}  

In addition you can set the AllowFiltering property of each column to True or False depending on whether you need to  enable or disable filtering for the column.

Thanks,
Princy
Tags
Grid
Asked by
vivek tamboli
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or