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

[Solved] Hierarchy Grid - Sorting & Paging

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 15 Mar 2013, 03:56 PM
I have a "Main" grid on the page which generates many reports based upon the user selection. 

Here is the code of the Grid:
<telerik:RadGrid ID="gvMainControl" runat="server" AutoGenerateColumns="true" GridLines="None"
    CellPadding="0" CellSpacing="0" AllowPaging="False" Skin="WebBlue" AllowSorting="true"
    ShowFooter="True" EnableLinqExpressions="false" AllowCustomPaging="false" >
    <MasterTableView TableLayout="Auto" AllowFilteringByColumn="False" PageSize="20"
        CommandItemDisplay="Top" AllowCustomPaging="false" >
    </MasterTableView>
</telerik:RadGrid>


Some of the reports requires Hierarchy Grids within the MasterTableView which we create once the user clicks the "Generate Report Button". Here is the code to add the DetailsTables on Button Click:        
    For i = 0 To intLevels
        Dim tableViewOrders As New Telerik.Web.UI.GridTableView()
        tableViewOrders.DataMember = dicTemp(i).GroupBy.GroupBy(0)
        gvMainControl.MasterTableView.DetailTables.Add(tableViewOrders)
    Next i


We use the NeedDataSource event to re-populate the main grid when needed:
Protected Sub gvMainControl_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gvMainControl.NeedDataSource
        gvMainControl.DataSource = reporting_service.Run(Of Reporting.Item_DrillDown)()
        gvMainControl.MasterTableView.DataKeyNames = {"Category_Name"}
        gvMainControl.MasterTableView.ClientDataKeyNames = {"Category_Name"}
End Sub

Expending the grids works well and the data is shown via DetailsTableDataBind:      
Protected Sub gvMainControl_DetailTableDataBind(sender As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles gvMainControl.DetailTableDataBind
 
    If e.DetailTableView.DataMember = "Item_Name" Then
        Dim strCategory_Name As String = CType(e.DetailTableView.ParentItem, Telerik.Web.UI.GridDataItem).GetDataKeyValue("Category_Name")
        e.DetailTableView.DataSource = New Reporting_Service.Query(Global.Reporting_Service.Query.Report_Type.Items, New Dictionary(Of String, String) From {{"Category_Name", strCategory_Name}}, _
                                                                        Nothing, New Reporting_Service.Query.Group(New List(Of String)({"Item_Name"}), New List(Of String)({"Quantity", "Total_Price"})), New List(Of String)({"Quantity"}), True, Nothing, Me.strUniqueID).Run(Of Reporting.Item_DrillDown)()
 
 
 
    End If

Problem starts when you try to Sort or Page in the inner Grids. It simply doesn't work. No event gets fired, not "NeedDataSource" or "DetailsTableDataBind". 

Your help is appreciated. 


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2013, 04:20 AM
Hi,

Please make sure that you have attached the events.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server"  OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource" ></telerik:RadGrid>

Thanks,
Shinu
0
Nick
Top achievements
Rank 1
answered on 18 Mar 2013, 09:47 AM
Shinu,

Needdatasource do fire when sorting the main table and when opening inner tables.

DetailsDataBind fires when opening inner tables. Both events do not fire when sorting / paging inner tables.

Nick
0
Kostadin
Telerik team
answered on 20 Mar 2013, 01:20 PM
Hello Nick,

I am afraid that you could not change the grid structure on button click event. You must ensure that the entire grid, including its detailed tables and columns, are modified on Page_Init so that the control ViewState remains consistent. I suggest you to check out the following help article which elaborates more on this matter.

All the best,
Kostadin
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.
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nick
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or