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

Hide/Show RadGrid Column Filter from code behind

3 Answers 423 Views
Grid
This is a migrated thread and some comments may be shown as answers.
scott
Top achievements
Rank 1
scott asked on 26 Feb 2013, 07:37 PM

Is there a way that I can conditionally hide a column filter in a RadGrid from the code behind based on the data column name when the RadGrid is set to AutoGenerateColumns="true"?

Example:
I assign a datatable as the RadGrid's datasource. I want to intercept some RadGrid event to see if column "TEST" was added, and if so, then hide the filter for that column in the RadGrid.


Thank you,

-Scott

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Feb 2013, 04:48 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
{
        if (e.Column is GridBoundColumn && e.Column.UniqueName=="Test")
        {
            GridBoundColumn column = e.Column as GridBoundColumn;
            column.AllowFiltering = false;
        }
}

Thanks,
Shinu
0
scott
Top achievements
Rank 1
answered on 27 Feb 2013, 04:56 PM
That worked great, Shinu! Thanks much!

-Scott
0
Wired_Nerve
Top achievements
Rank 2
answered on 01 Oct 2014, 08:40 PM
Perfect...
Tags
Grid
Asked by
scott
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
scott
Top achievements
Rank 1
Wired_Nerve
Top achievements
Rank 2
Share this question
or