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

Problem loading the Hierarchical Grid

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hitesh
Top achievements
Rank 1
Hitesh asked on 16 Aug 2012, 01:42 PM
Hi,

We are using the hierarchical functionality of the Telerik grid and we have hierarchy upto four level and the total records for all this levels comes upto around 1300 records and we are not applying any paging and when we try to run the page, it takes around 55 seconds to load the page and the html page size comes to around 4.5 MB.

we applied the compression technique as well but still the page was taking around 45 seconds to load with the viewstate which is required for the Hierarchical grid and also the loading time of the page is unacceptable to the Client.

We are attaching the source code. Please look into it and let us know if there is any optimization possible to speed up the execution time of the page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RelationGrid.aspx.cs" Inherits="RelationGrid"
    Debug="true" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <div>
    <% Response.Write(DateTime.Now.ToString()); %>
 
        <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" runat="server" ShowStatusBar="true"
            DataSourceID="SqlDataSource1" AutoGenerateColumns="False" AllowSorting="True"
            AllowMultiRowSelection="False" GridLines="None" EnableViewState="true" >
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="nGroupID" AllowMultiColumnSorting="True"
                HierarchyDefaultExpanded="true" >
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="nSubGroupID" DataSourceID="SqlDataSource2" Width="100%"
                        runat="server" HierarchyDefaultExpanded="true" EnableViewState="true" >
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="nGroupID" MasterKeyField="nGroupID" />
                        </ParentTableRelation>
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="QuoteSubID" DataSourceID="SqlDataSource3"
 
Width="100%"
                                runat="server" HierarchyDefaultExpanded="true" EnableViewState="true">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="nSubGroupID"
 
MasterKeyField="nSubGroupID" />
                                </ParentTableRelation>
                                <DetailTables>
                                    <telerik:GridTableView DataKeyNames="CatId" DataSourceID="SqlDataSource4"
 
Width="100%"
                                        runat="server" HierarchyDefaultExpanded="true" EnableViewState="true" >
                                        <ParentTableRelation>
                                            <telerik:GridRelationFields DetailKeyField="QuoteSubID"
 
MasterKeyField="QuoteSubID" />
                                        </ParentTableRelation>
                                        <Columns>
                                            <telerik:GridBoundColumn HeaderText="KIT ITEM" DataField="CDescription"
 
UniqueName="CDescription">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn HeaderText="Quantity" DataField="quotekitqty"
 
UniqueName="quotekitqty">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn HeaderText="Type" DataField="cattype"
 
UniqueName="cattype">
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </telerik:GridTableView>
                                </DetailTables>
                                <Columns>
                                    <telerik:GridBoundColumn HeaderText="QuoteSubID" DataField="QuoteSubID"
 
UniqueName="QuoteSubID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridCheckBoxColumn HeaderText="K" DataField="CatPrint"
 
UniqueName="CatPrint">
                                        <HeaderStyle Font-Bold="true" />
                                    </telerik:GridCheckBoxColumn>
                                    <telerik:GridCheckBoxColumn HeaderText="B" DataField="QuoteHeading"
 
UniqueName="QuoteHeading">
                                        <HeaderStyle Font-Bold="true" />
                                    </telerik:GridCheckBoxColumn>
                                    <telerik:GridCheckBoxColumn HeaderText="I" DataField="nItalic"
 
UniqueName="nItalic">
                                        <HeaderStyle Font-Bold="true" Font-Italic="true" />
                                    </telerik:GridCheckBoxColumn>
                                    <telerik:GridBoundColumn HeaderText="Use Quantity" DataField="Quantity"
 
UniqueName="Quantity">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Bill Quantity" DataField="BillQuantity"
 
UniqueName="Quantity">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Period" DataField="Period"
 
UniqueName="Period">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="CDescription" DataField="CDescription"
 
UniqueName="CDescription">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Note" DataField="QuoteDescription"
 
UniqueName="QuoteDescription">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Reg Rate" DataField="SuggestedRate"
 
UniqueName="SuggestedRate">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Disc%" DataField="DiscountPercent"
 
UniqueName="DiscountPercent">
                                        <HeaderStyle ForeColor="AliceBlue" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Disc Rate" DataField="DiscountRate"
 
UniqueName="DiscountRate">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Line Total" DataField="Sum"
 
UniqueName="Sum">
                                    </telerik:GridBoundColumn>
                                   
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        <Columns>
                            <%--<telerik:GridBoundColumn HeaderText="SubGroupID" DataField="nSubGroupID"
 
UniqueName="nSubGroupID">
                               <HeaderStyle BackColor="Gray" ForeColor="Red" />
                            </telerik:GridBoundColumn>--%>
                            <telerik:GridBoundColumn HeaderText="SubGroup Name" DataField="tSubGroupName"
 
UniqueName="tSubGroupName">
                                <ItemStyle BackColor="Gray" ForeColor="Red" />
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <%--<telerik:GridBoundColumn HeaderText="GroupID" DataField="nGroupID" UniqueName="nGroupID">
                      <HeaderStyle BackColor="Gray" ForeColor="Red" />
                    </telerik:GridBoundColumn>--%>
                    <telerik:GridBoundColumn HeaderText="GroupName" DataField="tGroupName" UniqueName="tGroupName">
                        <ItemStyle BackColor="Gray" ForeColor="Red" />
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="select * from GroupMaster with(noLock)
 
where tQuoteID =43617 ORDER BY (CASE WHEN tgroupname = '[EXTRAS]' THEN 99991 ELSE (case when
 
tgroupname='[ADJUSTMENTS]' then 99992 ELSE (case WHEN tgroupname='[INTERNAL USE ONLY]' THEN 99993 ELSE
 
tGroupLineNumber END) END) END ) "
            ConnectionString="<%$ ConnectionStrings:DatasetConnString %>"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:DatasetConnString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="select * from subgroupmaster with(noLock) where
 
ngroupid=@nGroupID order by tsubgrouplinenumber"
            runat="server">
            <SelectParameters>
                <asp:SessionParameter Name="nGroupID" SessionField="nGroupID" Type="string" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:DatasetConnString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT
    dbo.tblQuoteSub.QuoteSubSync,
    dbo.tblQuoteSub.QuoteSubID,
    dbo.tblQuoteSub.QuoteId,
    dbo.tblQuoteSub.nSubGroupID,  
    dbo.tblQuoteSub.nGroupID,
    dbo.tblQuoteSub.CatPrint,
    dbo.tblCat.CatType,
    dbo.tblQuoteSub.LineNumber,
    dbo.tblQuoteSub.QuoteHeading,
    dbo.tblQuoteSub.nItalic,
    dbo.tblQuoteSub.Quantity,
    dbo.tblQuoteSub.BillQuantity,
    dbo.tblQuoteSub.Period,
    dbo.tblQuoteSub.CategoryID,  
    dbo.tblCat.CDescription,
    dbo.tblQuoteSub.QuoteDescription,
    dbo.tblQuoteSub.SuggestedRate,
    dbo.tblQuoteSub.DiscountPercent,  
    dbo.tblQuoteSub.DiscountRate,
    (dbo.tblQuoteSub.SuggestedRate * dbo.tblQuoteSub.Period * dbo.tblQuoteSub.BillQuantity)  
    * (1 - CAST(dbo.tblQuoteSub.DiscountPercent AS float) / 100) AS [Sum],
    dbo.tblQuoteSub.QuoteKitParentId,
    dbo.tblQuoteSub.EquipTotal,  
    dbo.tblQuoteSub.EquipAvailable,
    dbo.tblQuoteSub.Equip_NonConfirmed,
    dbo.tblQuoteSub.CompanyWideEquipAvailable,  
    dbo.tblQuoteSub.QuoteSubParentId,
    dbo.tblQuoteSub.QuoteCancelParentId,
    dbo.tblQuoteSub.QuoteCancelChildId,  
    dbo.tblQuoteSub.QuoteSubstituteParentId,
    dbo.tblQuoteSub.QuoteFloatParentId,
    dbo.tblQuoteSub.QuoteSFRParentId,  
    dbo.tblQuoteSub.QuoteSFRChildId, dbo.tblQuoteSub.QuoteSubEnteredBy, dbo.tblQuoteSub.QuoteSubEnteredDate,  
    dbo.tblQuoteSub.QuoteSubLastModifiedBy, dbo.tblQuoteSub.QuoteSubLastModifiedDate,
 
dbo.tblQuoteSub.QuoteHeaderFooterId 
FROM 
       dbo.tblQuoteSub with(noLock) INNER JOIN 
                      dbo.tblCat with(noLock) ON dbo.tblQuoteSub.CategoryID = dbo.tblCat.CatId INNER JOIN 
                      dbo.SubGroupMaster with(noLock) ON dbo.tblQuoteSub.nSubGroupID =
 
dbo.SubGroupMaster.nSubGroupID INNER JOIN 
                      dbo.GroupMaster with(noLock) ON dbo.SubGroupMaster.nGroupID = dbo.GroupMaster.nGroupID 
where tblquotesub.quoteid=43617 and tblquotesub.nsubgroupid=@nSubGroupID and (quotekitparentid = 0 OR
 
QuoteKitParentID IS NULL)  
    
ORDER BY   dbo.tblQuoteSub.LineNumber" runat="server">
            <SelectParameters>
                <asp:SessionParameter Name="nSubGroupID" SessionField="nSubGroupID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
 
           <asp:SqlDataSource ID="SqlDataSource4" ConnectionString="<%$ ConnectionStrings:DatasetConnString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT  tblcat.cattype,tblCat.CDescription,
 
tblCat.CatId,  quotekitqty, tblquotesub.quotecatkitautoid, QuoteSubID,Quantity,BillQuantity ,
 
QuoteKitQty,QuoteKitParentId  FROM   tblQuoteSub with(noLock) INNER JOIN tblCat with(noLock) ON
 
tblQuoteSub.CategoryID = tblCat.CatId where QuoteKitParentId=@QuoteSubID  ORDER BY linenumber" runat="server">
            <SelectParameters>
               <asp:SessionParameter Name="QuoteSubID" SessionField="QuoteSubID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
         <% Response.Write(DateTime.Now.ToString()); %>
    </div>
    </form>
</body>
</html>

Regards,
Hitesh

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 21 Aug 2012, 08:33 AM
Hello,

 The problem is that you are trying to show a huge amount of data on the page (a total of more that 20000 cells) and when the whole hierarchy is expanded and you do not use paging it is expected to take a lot of time. You can check the additional optimization techniques here, but the best performance optimization can be achieved if you decrease the number of records shown in the grid.

All the best,
Marin
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
Hitesh
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or