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

how to set visibility of grid column to false?..

5 Answers 1911 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 25 Oct 2010, 12:12 PM
hey everyone,

How can i set a column's visibility to false?...I am using data table as radgrid's data source.

Thanks
Amit

5 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Oct 2010, 12:40 PM
Hello Amit,

The following code snippet shows how to hide grid column (AutoGeneratedColumn and GridBoundColumn).

C#:
protected void RadGrid2_PreRender(object sender, EventArgs e)
   {
       RadGrid2.MasterTableView.GetColumn("status").Visible = false;//hiding grid column using ColumnUniqueName
       RadGrid2.MasterTableView.AutoGeneratedColumns[0].Visible = false;// hiding AutoGeneratedColumn
   }

Thanks,
Princy.
0
Accepted
Dimo
Telerik team
answered on 25 Oct 2010, 12:45 PM
Hi Amit,

RadGrid columns have a Visible property and a Display property. More information about them is available in the documentation:

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html

If you use Display="false", you can toggle the column's visibility client-side using the control's API, in case you need such a functionality.

http://demos.telerik.com/aspnet-ajax/grid/examples/client/clientsideapi/defaultcs.aspx

In case you columns are autogenerated, you can set the properties in ColumnCreated, as demonstrated in the first document linked above.

Regards,
Dimo
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
0
Amit
Top achievements
Rank 1
answered on 28 Oct 2010, 10:36 AM
Hey Princy,

Thanks,thats done,but i was told that column index starts from 2.initial 2 columns are hidden.That does'nt look so?...
0
Accepted
Dimo
Telerik team
answered on 28 Oct 2010, 11:19 AM
Hello Amit,

>> "initial 2 columns are hidden."

This is true (unless the columns become visible), however it does not apply in your case. It applies when addressing row cells by index (which is generally not recommended):

item.Cells[2]

Sincerely yours,
Dimo
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
0
Amit
Top achievements
Rank 1
answered on 28 Oct 2010, 11:21 AM
Thanks for clarifying Dimo...
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dimo
Telerik team
Amit
Top achievements
Rank 1
Share this question
or