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

Hiding Column at Runtime

6 Answers 309 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DK
Top achievements
Rank 2
DK asked on 03 Dec 2009, 10:34 AM
Hi i am using radgrid.
I have two questions regarding this.

I have different dataset and single grid.
so I have not defined columns in the grid.
Columns are generated through the dataset columns.

1. Now i want to hide the first column of the grid.
2. I want to add a column for deleting the record.

How can i do this?
Please suggest me some idea...

6 Answers, 1 is accepted

Sort by
0
DK
Top achievements
Rank 2
answered on 03 Dec 2009, 10:59 AM
i ma trying the following code but it is not able to hide the column.
both of the following codes are not working for me

Private void RadGrid1_PreRender(Object sender,EventArgs e) 
{  
    If (RadGrid1.MasterTableView.RenderColumns.Length > 2) 
        RadGrid1.MasterTableView.RenderColumns[2].Display = False  
        RadGrid1.MasterTableView.RenderColumns[3].Display = False  
     
 
 
and also tried 
 
 
Private void RadGrid1_PreRender(Object sender,EventArgs e) 
{  
    If (RadGrid1.MasterTableView.RenderColumns.Length > 2) 
        RadGrid1.MasterTableView.RenderColumns[2].visible= False  
        RadGrid1.MasterTableView.RenderColumns[3].visible= False  
     

0
Pavlina
Telerik team
answered on 03 Dec 2009, 10:59 AM
Hi DK,

I assume you want to hide AutoGeneratedColumn from code behind. If so please try the following code snippet:
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (RadGrid1.MasterTableView.RenderColumns.Length > 2) {
        RadGrid1.MasterTableView.RenderColumns(2).Display = false;
    }
}

About your second question, please refer to these articles, for more information about how to achieve your goal.
Deleting records
Automatic operations

I hope this helps.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
DK
Top achievements
Rank 2
answered on 03 Dec 2009, 11:16 AM
you code

RadGrid1.MasterTableView.RenderColumns(2).Display = false;

giving error
Telerik.Web.UI.GridTableView.RenderColumns can not be used like a method..
now plz help me what to do now?

and also the links you provided is not as helpful as i want
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Dec 2009, 12:10 PM
Hi DK,

Try replacing the above code as shown below and see if it helps:
c#:
RadGrid1.MasterTableView.RenderColumns[2].Display = false

You can also use the following code to hide a column using the UniqueName of the column which is the same as the Datafield name of the column:
RadGrid1.MasterTableView.GetColumn("ColumnDataFieldName").Display = false;

Thanks
Princy.
0
swagatika
Top achievements
Rank 1
answered on 25 Nov 2014, 06:44 AM
WBSRadGrid.MasterTableView.GetColumn("ActualEndDate").Visible = false;
//or
            WBSRadGrid.MasterTableView.Columns.FindByUniqueName("ActualEndDate").Visible 

= false;

0
swagatika
Top achievements
Rank 1
answered on 25 Nov 2014, 07:02 AM
WBSRadGrid.MasterTableView.GetColumn("ActualEndDate").Visible = false;
//or
            WBSRadGrid.MasterTableView.Columns.FindByUniqueName("ActualEndDate").Visible 

= false;

Tags
Grid
Asked by
DK
Top achievements
Rank 2
Answers by
DK
Top achievements
Rank 2
Pavlina
Telerik team
Princy
Top achievements
Rank 2
swagatika
Top achievements
Rank 1
Share this question
or