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

[Solved] Hierarchy Showing Parent information in Child Records

4 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Kucharski
Top achievements
Rank 1
David Kucharski asked on 30 Apr 2013, 04:27 PM
I have created a RadGrid in the Page_init and have declared a GridTableView to incorporate the hierarchy.

RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
Dim tableSubCode As New GridTableView(RadGrid1)
tableSubCode.Name = "SubCodes"
tableSubCode.Width = Unit.Percentage(100)
Dim relationFields1 As GridRelationFields = New GridRelationFields()
relationFields1.MasterKeyField = "DetailID"
relationFields1.DetailKeyField = "DetailID"
tableSubCode.ParentTableRelation.Add(relationFields1)
RadGrid1.MasterTableView.DetailTables.Add(tableSubCode)
columnSubCodeCreation("SubCode", "Sub_Code", tableSubCode)
columnSubCodeCreation("Household", "HouseHold_Count", tableSubCode)
If mstrClientDataCategoryID1Description.Trim <> "" Then
    columnSubCodeCreation(mstrClientDataCategoryID1Description.Trim, "CD1", tableSubCode)
End If
If mstrClientDataCategoryID2Description.Trim <> "" Then
    columnSubCodeCreation(mstrClientDataCategoryID2Description.Trim, "CD2", tableSubCode)
End If
If mstrClientDataCategoryID3Description.Trim <> "" Then
    columnSubCodeCreation(mstrClientDataCategoryID3Description.Trim, "CD3", tableSubCode)
End If
If mstrReportDemographicID1Description.Trim <> "" Then
    columnSubCodeCreation(mstrReportDemographicID1Description.Trim, "Demographic1", tableSubCode)
End If
If mstrReportDemographicID2Description.Trim <> "" Then
    columnSubCodeCreation(mstrReportDemographicID2Description.Trim, "Demographic2", tableSubCode)
End If
If mstrReportDemographicID3Description.Trim <> "" Then
    columnSubCodeCreation(mstrReportDemographicID3Description.Trim, "Demographic3", tableSubCode)
End If
If mstrReportDemographicID4Description.Trim <> "" Then
    columnSubCodeCreation(mstrReportDemographicID4Description.Trim, "Demographic4", tableSubCode)
End If
If mstrReportDemographicID5Description.Trim <> "" Then
    columnSubCodeCreation(mstrReportDemographicID5Description.Trim, "Demographic5", tableSubCode)
End If
columnSubCodeCreation("Selected", "Selected", tableSubCode)
If UcHeader.objSession.ApplicationId <> CInt(ConfigurationManager.AppSettings("MediaviewerAppID")) Then
    columnSubCodeCreation("Forced", "Forced", tableSubCode)
End If
columnSubCodeCreation("Circ", "Circ", tableSubCode)
columnSubCodeCreation("Coverage", "Coverage", tableSubCode)
If UcHeader.objSession.ApplicationId <> CInt(ConfigurationManager.AppSettings("MediaviewerAppID")) Then
    Dim dpCounter As Integer = 1
    Dim dpCollection As IList(Of RadListBoxItem) = rlbDistributionPatterns.CheckedItems
    For Each item As RadListBoxItem In dpCollection
        columnSubCodeCreation(item.Text, "DP" & dpCounter.ToString, tableSubCode)
        dpCounter += 1
    Next
End If

My Hierarchy is expanded as a default. So the RadGrid1_DetailTableDataBind is called for every parent row about 1200 with a pagesize of 100. I only want to set the datasource when dealing with 3 of my parents.
Private Sub RadGrid1_DetailTableDataBind(sender As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind
    Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
    Select Case e.DetailTableView.Name
        Case "SubCodes"
            Dim detailID As Integer = dataItem.GetDataKeyValue("DetailID").ToString()
            'Dim Geography As String = dataItem.GetDataKeyValue("Geography").ToString()
            'Dim CirculationTypeID As Integer = dataItem.GetDataKeyValue("CirculationTypeID").ToString()
            Dim Day As String = dataItem.GetDataKeyValue("Day").ToString()
            If mintCircSetID > 0 And (detailID = 29 Or detailID = 506 Or detailID = 509) Then
                e.DetailTableView.DataSource = GetDataTable(mstrSQL & ",1," & detailID & ",'" & Day & "'")
            End If
    End Select
End Sub

When I do this, for the parent rows that I do not want to call the datasource, a Child View does come up with the Parents information in it. For the 3 rows I actually call, the correct information comes up. I do not want the Child View of the other parents to show. I am doing this this way for effeciency. I see my performance times greatly shrink if I only assign the datasource to the parents I want and not have the call to every parent. How can I stop from the child view showing up on the other parents?

4 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 03 May 2013, 01:24 PM
Hello David,

Set:
HierarchyDefaultExpanded=false
HierarchyLoadMode = HierarchyLoadMode.ServerOnDemand;
for your MasterTableView.
Check this help topic for more information:
http://www.telerik.com/help/aspnet-ajax/grid-hierarchy-load-modes.html

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 03 May 2013, 01:48 PM
Unfortunately my users want the hierarchy expanded as a default. I understand that the DetailTableDataBind has to be called for every parent, what I don't understand is why if I only set the e.DetailTableView.DataSource to a select number of parent, the other parents come up with their information in the hierarchy section.
0
Accepted
Vasil
Telerik team
answered on 08 May 2013, 10:56 AM
Hi David,

Not exactly sure what is causing your problem, since I don't have your full code. But you can try to handle the DetailTableDataBind and set empty DataSource for your detail tables.

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David Kucharski
Top achievements
Rank 1
answered on 08 May 2013, 03:17 PM
I believe that did the trick. Thanks
Tags
Grid
Asked by
David Kucharski
Top achievements
Rank 1
Answers by
Vasil
Telerik team
David
Top achievements
Rank 1
David Kucharski
Top achievements
Rank 1
Share this question
or