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

Hide column in detailtable

3 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 1
Iron
Veteran
Iron
Morten asked on 29 Jun 2010, 12:25 AM
How can I hide a column in a detail table (code behind). I already tried the "ComumnCreated" event, but UniqueName is always "ExpandColumn"...

ASPX:

<

 

 

telerik:GridTemplateColumn HeaderText="Ansvarligt kontor" UniqueName="AnsvarligtKontor" >

VB:

 

 

 

Private

 

 

Sub rgStrategiskPrioritering_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles rgStrategiskPrioritering.ColumnCreated

 

 

 

   Response.Write(

 

"ColumnName: " & e.Column.UniqueName)

 

 

 

End Sub

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jun 2010, 07:26 AM
Hello Morten,

If you are using  AutoGeneratedColumn in DetailTable, then you can try in grid's ColumnCreated event like below.

VB.NET:
 
 Protected Sub RadGrid1_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs) 
    If TypeOf e.Column Is GridBoundColumn AndAlso e.Column.UniqueName = "ColumnUniqueName" Then 
        TryCast(e.Column, GridBoundColumn).Visible = False 
    End If 
 End Sub 
 

Or if you want to hide any declarative columns in DetailTable at runtime, you can try in PreRender event of grid like below.

VB.NET:
 
 Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) 
    RadGrid1.MasterTableView.DetailTables(0).GetColumn("ColumnUniqueName").Visible = False 
 End Sub 
 

Thanks,
Princy.





0
Morten
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 29 Jun 2010, 09:22 AM
Hi,

I tried what you are suggesting but nothing is working...

 

 

Private Sub rgStrategiskPrioritering_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgStrategiskPrioritering.PreRender

 

 

 

Me.rgStrategiskPrioritering.MasterTableView.DetailTables(0).GetColumn("AnsvarligtKontor").Visible = False

 

 

 

End Sub

Any other suggestions?

 

0
Martin
Telerik team
answered on 01 Jul 2010, 02:12 PM
Hello Morten,

I have attached a small sample project that demonstrates the desired functionality. Please give it a try and let me know how it goes on your side.

Regards,
Martin
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
Tags
Grid
Asked by
Morten
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Princy
Top achievements
Rank 2
Morten
Top achievements
Rank 1
Iron
Veteran
Iron
Martin
Telerik team
Share this question
or