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

Apply Filter to grid with autogenerate column = true

1 Answer 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Archana
Top achievements
Rank 1
Archana asked on 11 Jul 2011, 07:47 AM
Hi ,

Your reqirement is like one control will have rad grid with autogenerate column = true. And dynamically according to the page type the datasource will be set i.e. like if page is for customer then  list of customer will be there. If page is for product then product list will be the datasource for radgrid. Also we are goinig to have filters in each page for each cloumns.
Here my question is how can i apply filter to columns which are auto generated?

Thanks in advance.
Let me know if more info is neeeded.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Jul 2011, 08:13 AM
Hello Archana,

In order to achieve this attach ColumnCreated event to your RadGrid and enable filtering for columns. Hope this helps.

C#:
protected void RadGrid1_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
{
        if (e.Column is GridBoundColumn)
        {
            GridBoundColumn col = (GridBoundColumn)e.Column;
            if (col.UniqueName == "ColumnUniqueName")
            {
                col.AllowFiltering = true;
                col.CurrentFilterFunction = GridKnownFunction.Contains;
                col.CurrentFilterValue = "4";
            }         
        }
}

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