Problem loading data hierarchy mode

3 posts, 0 answers
  1. Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 15 Feb 2009 Link to this post

    Good day there, I have recently started using Telerik Radcontrols and I must say they are awesome. Since I am still new at this, I have been experiencing a problem loading data in Hierarchy mode "old master detail" style in my grid. I have done reading and research but can't seem to get it right. Could you please assist me :)

    Here are the details. I would like to load a grid, displaying companies, and on the following hierarchy, customers that belong to this company. I have a customer table, a company table, and a customer_company table that links the two with a companyid and a customer id.

    Here is my aspx.

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Company.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br /><br /><br /><br /><br /><br />
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowCustomPaging="True" AllowPaging="True" OnItemCommand="RadGrid1_ItemCommand" Skin="WebBlue">
    <HeaderContextMenu EnableTheming="True">
    <CollapseAnimation Duration="200" Type="OutQuint" />
    </HeaderContextMenu>
    <ClientSettings AllowExpandCollapse="True">
    </ClientSettings>
    <MasterTableView AllowMultiColumnSorting="True" HierarchyLoadMode="client" HierarchyDefaultExpanded="true" DataSourceID="SqlDataSource1" CommandItemDisplay="Top" AllowFilteringByColumn="True" AutoGenerateColumns="False" DataKeyNames="com_cde" AllowSorting="True">
    <RowIndicatorColumn>
    <HeaderStyle Width="20px" />
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px" />
    </ExpandCollapseColumn>
    <DetailTables>
    <telerik:GridTableView DataKeyNames="com_cde" DataSourceID="SqlDataSource1" Width="100%" runat="server">
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="com_cde" MasterKeyField="com_cde" />
    </ParentTableRelation>
    <DetailTables>
    <telerik:GridTableView DataKeyNames="cnt_prs_cde" DataSourceID="SqlDataSource3" Width="100%" runat="server">
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="cnt_prs_cde" MasterKeyField="cnt_prs_cde" />
    </ParentTableRelation>
    <Columns>
    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
    <telerik:GridClientDeleteColumn ConfirmText="Are you sure you wish to delete this contact person?" ConfirmTitle="Delete contact person" Text="Delete" UniqueName="column"></telerik:GridClientDeleteColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_cde" DataType="System.Int32" HeaderText="Code"
    ReadOnly="True" SortExpression="cnt_prs_cde" UniqueName="cnt_prs_cde">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_nme" HeaderText="Name" SortExpression="cnt_prs_nme"
    UniqueName="cnt_prs_nme">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_sur_nme" HeaderText="Surname"
    SortExpression="cnt_prs_sur_nme" UniqueName="cnt_prs_sur_nme">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_cel_nbr" HeaderText="Cell number"
    SortExpression="cnt_prs_cel_nbr" UniqueName="cnt_prs_cel_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_fax_nbr" HeaderText="Fax number"
    SortExpression="cnt_prs_fax_nbr" UniqueName="cnt_prs_fax_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_eml_adr_wrk" HeaderText="Work email"
    SortExpression="cnt_prs_eml_adr_wrk" UniqueName="cnt_prs_eml_adr_wrk">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_eml_adr_alt" HeaderText="Alternatative email"
    SortExpression="cnt_prs_eml_adr_alt" UniqueName="cnt_prs_eml_adr_alt">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="cnt_prs_wrk_nbr" HeaderText="Work number"
    SortExpression="cnt_prs_wrk_nbr" UniqueName="cnt_prs_wrk_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridCheckBoxColumn DataField="acv_ind" DataType="System.Boolean" HeaderText="Active"
    SortExpression="acv_ind" UniqueName="acv_ind">
    </telerik:GridCheckBoxColumn>
    </Columns>
    </telerik:GridTableView>
    </DetailTables>
    <Columns>
    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
    <telerik:GridClientDeleteColumn ConfirmText="Are you sure you wish to delete this company?" ConfirmTitle="Delete company" Text="Delete" UniqueName="column"></telerik:GridClientDeleteColumn>
    <telerik:GridBoundColumn DataField="com_cde" DataType="System.Int32" HeaderText="Code"
    ReadOnly="True" SortExpression="com_cde" UniqueName="com_cde">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_nme" HeaderText="Name" SortExpression="com_nme"
    UniqueName="com_nme">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_reg_nbr" HeaderText="Registration no" SortExpression="com_reg_nbr"
    UniqueName="com_reg_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_inc_dte" DataType="System.DateTime" HeaderText="Incorporation date"
    SortExpression="com_inc_dte" UniqueName="com_inc_dte">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_inc_tax_nbr" HeaderText="Incorporation tax no"
    SortExpression="com_inc_tax_nbr" UniqueName="com_inc_tax_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_vat_nbr" HeaderText="Vat no" SortExpression="com_vat_nbr"
    UniqueName="com_vat_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="com_paye_nbr" HeaderText="Paye nr" SortExpression="Paye nr"
    UniqueName="com_paye_nbr">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="acv_ind" DataType="System.Int32" HeaderText="Active"
    SortExpression="acv_ind" UniqueName="acv_ind">
    </telerik:GridBoundColumn>
    </Columns>
    </telerik:GridTableView>
    </DetailTables>
    <EditFormSettings>
    <EditColumn UniqueName="EditCommandColumn1">
    </EditColumn>
    </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableTheming="True">
    <CollapseAnimation Duration="200" Type="OutQuint" />
    </FilterMenu>
    <AlternatingItemStyle BackColor="White" VerticalAlign="Middle" />
    </telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AccbizConnectionString %>"
    DeleteCommand="spAccbiz_company_delete" DeleteCommandType="StoredProcedure" InsertCommand="spAccbiz_company_insert"
    InsertCommandType="StoredProcedure" SelectCommand="spAccbiz_get_company" SelectCommandType="StoredProcedure"
    UpdateCommand="spAccbiz_company_update" UpdateCommandType="StoredProcedure">
    <DeleteParameters>
    <asp:Parameter Name="com_cde" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:Parameter Name="com_cde" Type="Int32" />
    <asp:Parameter Name="com_nme" Type="String" />
    <asp:Parameter Name="com_reg_nbr" Type="String" />
    <asp:Parameter Name="com_inc_dte" Type="DateTime" />
    <asp:Parameter Name="com_inc_tax_nbr" Type="String" />
    <asp:Parameter Name="com_vat_nbr" Type="String" />
    <asp:Parameter Name="com_paye_nbr" Type="String" />
    <asp:Parameter Name="com_typ_cde" Type="Int32" />
    <asp:Parameter Name="acv_ind" Type="Boolean" />
    </UpdateParameters>
    <InsertParameters>
    <asp:Parameter Name="com_nme" Type="String" />
    <asp:Parameter Name="com_reg_nbr" Type="String" />
    <asp:Parameter Name="com_inc_dte" Type="DateTime" />
    <asp:Parameter Name="com_inc_tax_nbr" Type="String" />
    <asp:Parameter Name="com_vat_nbr" Type="String" />
    <asp:Parameter Name="com_paye_nbr" Type="String" />
    <asp:Parameter Name="com_typ_cde" Type="Int32" />
    <asp:Parameter Name="acv_ind" Type="Boolean" />
    </InsertParameters>
    </asp:SqlDataSource>
    &nbsp;
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AccbizConnectionString%>"
    DeleteCommand="spAccbiz_contact_person_delete" DeleteCommandType="StoredProcedure"
    InsertCommand="spAccbiz_contact_person_insert" InsertCommandType="StoredProcedure"
    SelectCommand="spAccbiz_contact_person_exists" SelectCommandType="StoredProcedure"
    UpdateCommand="spAccbiz_contact_person_update" UpdateCommandType="StoredProcedure">
    <DeleteParameters>
    <asp:Parameter Name="cnt_prs_cde" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:Parameter Name="cnt_prs_cde" Type="Int32" />
    <asp:Parameter Name="cnt_prs_nme" Type="String" />
    <asp:Parameter Name="cnt_prs_sur_nme" Type="String" />
    <asp:Parameter Name="cnt_prs_cel_nbr" Type="String" />
    <asp:Parameter Name="cnt_prs_fax_nbr" Type="String" />
    <asp:Parameter Name="cnt_prs_eml_adr_wrk" Type="String" />
    <asp:Parameter Name="cnt_prs_eml_adr_alt" Type="String" />
    <asp:Parameter Name="cnt_prs_wrk_nbr" Type="String" />
    <asp:Parameter Name="acv_ind" Type="Boolean" />
    </UpdateParameters>
    <InsertParameters>
    <asp:Parameter Name="cnt_prs_cde" Type="Int32" />
    <asp:Parameter Name="cnt_prs_nme" Type="String" />
    <asp:Parameter Name="cnt_prs_sur_nme" Type="String" />
    <asp:Parameter Name="cnt_prs_cel_nbr" Type="String" />
    <asp:Parameter Name="cnt_prs_fax_nbr" Type="String" />
    <asp:Parameter Name="cnt_prs_eml_adr_wrk" Type="String" />
    <asp:Parameter Name="cnt_prs_eml_adr_alt" Type="String" />
    <asp:Parameter Name="cnt_prs_wrk_nbr" Type="String" />
    <asp:Parameter Name="acv_ind" Type="Boolean" />
    </InsertParameters>
    <SelectParameters>
    <asp:SessionParameter Name="com_cde" SessionField="com_cde" Type="Int32" />
    </SelectParameters>
    </asp:SqlDataSource>
    </asp:Content>

    Here is examples of my sql that is executing. datasource 1 selects * from company, and datasource 2 selects * from customer where the customer code is associated with the company code in the company_customer table.

    Can anybody please let me know what I am doing that is incorrect? Do I need to explicitly state a grouping field (tried, made no difference).....

    Thank you in advance.

    RB

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 18 Feb 2009 Link to this post

    Hello Riaan,

    One thing that I spotted was that you use SqlDataSource1 for both the master and the detail table. Please, make sure that you use different datasources for the respective levels. One similar implementation is shown in the following example. Take a look at it and see how it meets your requirements.
    I hope this gets you started properly.

    Best wishes,
    Yavor
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 20 Feb 2009 Link to this post

    Thanks Yavor. That was part of the issue. I also had two detail sections :|

    I sorted it out by looking at the examples.

    Regards,

    RB

Back to Top