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

Show and hide column in hirarchial grid

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ash
Top achievements
Rank 1
Ash asked on 27 Aug 2008, 12:38 PM
hi Telerik
I want to show/hide one column in hirarchial grid with 2 nested detail tables on the click of a checkbox or a button. kindly help me on how to do this. I have tried the following by placing it at various places in rad grid pre render event or on click of button or on click of checkbox. but the problem is that it does show the column but without the column header. though column header text does exist in the aspx page.


foreach

(GridDataItem item in RadGrid1.Items)

{

if (item.OwnerTableView.Name != "Signpost")

{

GridBoundColumn detailColumn = (GridBoundColumn)item.OwnerTableView.GetColumn("overview");

detailColumn.Display =

true;

detailColumn.Visible =

true;

item[

"overview"].Visible = true;

 }

}

kindly help on how to get this working.i have seen all set of examples for this on the forum but couldnt get it done for myself.

ASP.Net version is 2.0 and Rad controls for asp.net ajax  2008 Q1

 many thanks and best regards
Ash

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Aug 2008, 05:17 AM
Hello Ash,

I tried the following code which is very similar to your code with slight changes and its working fine. You can try this out and see if it helps.
aspx:
 <DetailTables> 
        <telerik:GridTableView Name="Detail" DataSourceID="SqlDataSource1" runat="server"
        <Columns> 
        <telerik:GridBoundColumn DataField="PlaceFrom" HeaderText="Place" Display="false" UniqueName="PlaceFrom"></telerik:GridBoundColumn> 
        </Columns>              
        </telerik:GridTableView> 
 </DetailTables>        


cs:
 protected void Button1_Click(object sender, EventArgs e) 
    {        
        foreach (GridDataItem items in RadGrid1.MasterTableView.Items) 
        { 
            if ((items.Expanded) && (items.OwnerTableView.Name != "Signpost")) 
                { 
                    items.ChildItem.NestedTableViews[0].GetColumn("PlaceFrom").Display = true
                } 
        } 
    } 

Princy.

0
Ash
Top achievements
Rank 1
answered on 28 Aug 2008, 12:53 PM
Excellent!!

Thanks a lot Princy for your prompt reply and u saved my day.Its working.
Cheers Telerik Team!!

Many Thanks
Best Regards
Ash
Tags
Grid
Asked by
Ash
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ash
Top achievements
Rank 1
Share this question
or