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

Hide Headers declaratively in detail tables?

4 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 23 Jan 2009, 09:02 PM
Good day.. busy day on the forums for me. sadly.
Mastertable view has two DetailTables within it. They are nested as :
<MasterTableView>
    <DetailTable>
    </DetailTable>
    <DetailTable>
    </DetailTable>
</MasterTableView>

I need to evaluate whether or not there are records within the detailtable and if the detailtable is emplty, then hide the header. Problem is that I can't see where or how to count the records when the mastertable is expanded. I have tried to run RemoveHeaders()  within the radgrid pre_render, DetailTableDataBound, ItemDatabound and ItemDataBinding.. but none are working as expected. thank you for any assistance you can provide.
mac
code is as follows
Protected Sub RadGrid1_DetailTableDataBind(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind  
        removeheaders()  
    End Sub  
 
Sub removeheaders()  
 
        ' RadGrid1.Controls.Add(New LiteralControl(RadGrid1.MasterTableView.DetailTables.Count)) //This should return mastertable recordcount  
        ' RadGrid1.Controls.Add(New LiteralControl(RadGrid1.MasterTableView.DetailTables(0).Items.Count))//This should return Detail 1 recordcount  
        ' RadGrid1.Controls.Add(New LiteralControl(RadGrid1.MasterTableView.DetailTables(1).Items.Count))//This should return Detail 2 recordcount  
 
        For i As Integer = 0 To RadGrid1.MasterTableView.DetailTables.Count - 1 ' Count the Detail table within MasterTable  
            If RadGrid1.MasterTableView.DetailTables(i).Items.Count <= 0 Then  
                RadGrid1.MasterTableView.DetailTables(i).ShowHeader = False 
            Else  
                RadGrid1.MasterTableView.DetailTables(i).ShowHeader = True 
            End If  
 
        Next  
End Sub
 


4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 27 Jan 2009, 07:50 AM
Hi mac,

You could try hiding the headers on RadGrid.PreRender by looping through all nested GridTableViews and setting the header items display Style property to none.

However, I suggest that you look at this article describing how to hide expand/collapse images when no records.

Check it out and let me know if any issues arise.

Kind regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kenneth Mazur
Top achievements
Rank 1
answered on 27 May 2009, 06:07 AM
If the GridTableViews are being generated dynamically and added to the MasterTableView, and one is using the DetailTableDataBind to fill it with data, how can the "expand/collapse" image be turned off.

I've tried the RadGrid.Pre_Render event using the HideExpandColumnRecursive function found in one of your examples.  But the DetailTableDataBind event isn't getting fired before the Pre_Render event.

I've tried setting the GridTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind in the Page_Init event where I generate the entire RadGrid and GridTableViews dynamically.  But it still does not fire the DetailTableDataBind event prior to the Pre_Render event.

Any ideas.
0
Iana Tsolova
Telerik team
answered on 27 May 2009, 08:44 AM
Hello Kenneth,

I followed your scenario and prepared a sample project for you attached to this post. PLease try it on your end and see if it works for you.

Let me know if I missed something from your logic.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan
Top achievements
Rank 1
answered on 20 Mar 2012, 06:42 PM
Is there an updated page for this link? I would like to hide the expand/collapse images when a given detail table contains no records.

For anyone else looking, the correct link is here: http://www.telerik.com/help/aspnet-ajax/grid-hide-expand-collapse-images-when-no-records.html
Tags
Grid
Asked by
mac
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Kenneth Mazur
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Share this question
or