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

HierarchyIndex property always returns zero

4 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
isocum
Top achievements
Rank 1
isocum asked on 23 Mar 2010, 03:09 PM
i am using a radgrid with 3 level hierarchy. it was working perfectly until a few days ago, but it simply doesn't work now. the hierarchy index should come either as a single digit n or n_m format, but in client and server load modes, i always get 0, regardless of level. serverOnDemand mode returns either 0 or 0_0. thus i can't bind the proper data in the nested grids. can anyone help?

here is aspx and codebehind:

<telerik:RadAjaxPanel> 
<div id="pnlResult" runat="server" visible="true"
                <div class="pageHeader"
                    <asp:Label ID="lblResultLegend" runat="server" Text="Sulama Suyu Raporu"></asp:Label> 
                </div> 
                <telerik:RadGrid ID="gridResult" runat="server" Width="95%" ShowStatusBar="true" 
                    AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False" 
                    AllowPaging="true" PageSize="10" Visible="false" OnDetailTableDataBind="gridResult_DetailTableDataBind"
                    <PagerStyle Mode="NumericPages"></PagerStyle> 
                    <MasterTableView ShowHeadersWhenNoRecords="true" Font-Names="Tahoma" DataKeyNames="NO"
                        <DetailTables> 
                            <telerik:GridTableView Name="Summary"
                                <Columns> 
                                    <telerik:GridBoundColumn SortExpression="Ay" HeaderText="Ay" HeaderButtonType="TextButton" 
                                        DataField="Ay"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="B" HeaderText="B" HeaderButtonType="TextButton" 
                                        DataField="B"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="EC" HeaderText="EC" HeaderButtonType="TextButton" 
                                        DataField="EC"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="RSC" HeaderText="RSC" HeaderButtonType="TextButton" 
                                        DataField="RSC"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="RSCGORE" HeaderText="RSC'ye GÖRE" HeaderButtonType="TextButton" 
                                        DataField="RSCGORE"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="SAR" HeaderText="SAR" HeaderButtonType="TextButton" 
                                        DataField="SAR"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="SulamaSuyuSinifi" HeaderText="SSS" HeaderTooltip="Sulama Suyu Sınıfı" 
                                        HeaderButtonType="TextButton" DataField="SulamaSuyuSinifi"
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="SulamaSuyuKalite" HeaderText="Kalite Durumu" 
                                        HeaderTooltip="Kalite Durumu" HeaderButtonType="TextButton" DataField="SulamaSuyuKalite"
                                    </telerik:GridBoundColumn> 
                                </Columns> 
                                <DetailTables> 
                                    <telerik:GridTableView Name="Detail"
                                        <Columns> 
                                            <telerik:GridBoundColumn SortExpression="Parametre" HeaderText="Parametre" HeaderButtonType="TextButton" 
                                                DataField="Parametre"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn SortExpression="Deger" HeaderText="Deger" HeaderButtonType="TextButton" 
                                                DataField="Deger" UniqueName="Deger"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn SortExpression="Sinif" HeaderText="Sınıf" HeaderButtonType="TextButton" 
                                                DataField="Sinif" UniqueName="Sinif"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn SortExpression="Birim" HeaderText="Birim" HeaderButtonType="TextButton" 
                                                DataField="Birim" UniqueName="Birim"
                                            </telerik:GridBoundColumn> 
                                        </Columns> 
                                    </telerik:GridTableView> 
                                </DetailTables> 
                            </telerik:GridTableView> 
                        </DetailTables> 
                        <Columns> 
                            <telerik:GridBoundColumn SortExpression="AD" HeaderText="Istasyon Adi" HeaderButtonType="TextButton" 
                                DataField="AD"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn SortExpression="NO" HeaderText="Istasyon No" HeaderButtonType="TextButton" 
                                DataField="NO"
                            </telerik:GridBoundColumn> 
                        </Columns> 
                        <CommandItemTemplate> 
                            <div style="width: 100%; float: left;"
                                <div> 
                                    <strong> 
                                        <asp:Label ID="lblResultBolgeTanim" runat="server" Text="Bölge: " Width="100px"></asp:Label></strong
                                    <asp:Label ID="lblResultBolge" runat="server" Text="" Width="150px"></asp:Label> 
                                </div> 
                                <div> 
                                    <strong> 
                                        <asp:Label ID="lblResultHavzaTanim" runat="server" Text="Havza: " Width="100px"></asp:Label></strong
                                    <asp:Label ID="lblResultHavza" runat="server" Text="" Width="150px"></asp:Label> 
                                </div> 
                                <div> 
                                    <strong> 
                                        <asp:Label ID="lblResultAyTanim" runat="server" Text="Ay: " Width="100px"></asp:Label></strong
                                    <asp:Label ID="lblResultAy" runat="server" Text="" Width="150px"></asp:Label> 
                                    <asp:HiddenField ID="hd_ResultAy" runat="server" /> 
                                </div> 
                                <div> 
                                    <strong> 
                                        <asp:Label ID="lblResultYilTanim" runat="server" Text="Yıl: " Width="100px"></asp:Label></strong
                                    <asp:Label ID="lblResultYil" runat="server" Text="" Width="150px"></asp:Label> 
                                </div> 
                            </div> 
                        </CommandItemTemplate> 
                    </MasterTableView> 
                    <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" 
                        FileName="SulamaSuyu"
                        <Pdf PageTitle="Sulama Suyu Listesi" PaperSize="A4" Author="DSI" PageWidth="100%" /> 
                    </ExportSettings> 
                </telerik:RadGrid> 
            </div> 
            <%-- SuKalitesi Suyu Result --%> 
        </div> 
    </telerik:RadAjaxPanel> 

protected
 void gridResult_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) 
        { 
 
 
            string hierarchy = e.DetailTableView.HierarchyIndex; 
            string[] temp = hierarchy.Split('_'); 
            int[] index = new int[temp.Length]; 
            for (int i = 0; i < temp.Length; i++) 
            { 
                index[i] = int.Parse(temp[i]); 
            } 
            DataTable dt = (e.DetailTableView.Name == "Detail") ? ((DataTable[][])Session["SulamaSuyu.detailTable"])[index[0]][index[1]] : 
            ((DataTable[])Session["SulamaSuyu.summaryTable"])[index[0]]; 
            e.DetailTableView.DataSource = dt; 
 
            
        } 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Mar 2010, 06:45 PM
Hello,

I created a sample project based on the code you posted below. Unfortunately I'm unable to reproduce this problem. Please download the demo and let me know whether it exhibits the same behavior on your end.

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
isocum
Top achievements
Rank 1
answered on 27 Mar 2010, 09:08 AM
nope, the problem still persists. the index in the screenshot should have been 9_4, but i am getting 0_0 instead. thus i can't properly bind my data.
0
Accepted
Daniel
Telerik team
answered on 01 Apr 2010, 09:31 AM
Hello,

I recommend you try the following approach:
protected void gridResult_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
    string hierarchyIndex = e.DetailTableView.ParentItem.ItemIndexHierarchical;
    ...
}

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
isocum
Top achievements
Rank 1
answered on 01 Apr 2010, 09:57 AM
Thanks Daniel, e.DetailTableView.ParentItem.ItemIndexHierarchical returns a string like "linenumber:0_sublinenumber", which solves the problem. I still have no idea why the previous code stopped working though.
Tags
Grid
Asked by
isocum
Top achievements
Rank 1
Answers by
Daniel
Telerik team
isocum
Top achievements
Rank 1
Share this question
or