TreeList from DataTable

2 posts, 0 answers
  1. Gabe
    Gabe avatar
    8 posts
    Member since:
    Jun 2012

    Posted 24 Sep 2013 Link to this post

    I'm trying to connect my datasource (from sproc) to a radtreelist control.

    I have added multiple levels with null values in the hierarchy to try to match the requirements for null values to set the nested levels but I am still getting "No records".

    Here's a sample of my data:

    wbs1        wbs2    wbs3    Name                                                                          PreConDate  DaysSincePrecon
    2009.0257   ESTR.1             
    2009.0257   ESTR.1  U0001   31 Drakestown Road - Main Project   08/04/2010  1147
    2009.0257   LEED.1             
    2009.0257   LEED.1  U0001   31 Drakestown Road - Main Project   08/04/2010  1147
    2010.0662   GRES.1             
    2010.0662   GRES.1  U0001   102 Creekview Drive 05/24/2013  123
    2010.0662   GRES.1  U0002   170E Monmouth Street    05/24/2013  123

    What I'm trying to do, is display a page of project numbers (wbs1) all condensed. When I click on the "expand" icon, I'd like it to show all levels that have only the second level (wbs2) and no third level (wbs3). And when I click "expand" on the wbs2, I'd like it to display all of the rows that share the wbs2.  I can change the sproc so that it gives me any configuration, i.e. nulls at some level, 0 at some level, etc.

    Here's my aspx code:
    <telerik:RadTreeList ID="RadTreeList1" runat="server" DataKeyNames="wbs3" ParentDataKeyNames="wbs1"
            Width="800px" Skin="Windows7" GridLines="Both" AutoGenerateColumns="true" DataSourceId="SqlDataSource1" >

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SqlConnectionString %>"
            SelectCommand="dbo.getDataSproc" SelectCommandType="StoredProcedure">

    Thanks in advance.
  2. Marin
    Marin avatar
    1038 posts

    Posted 27 Sep 2013 Link to this post


     The data in the table should have a foreign key relationship that will actually specify the hierarchical structure. It can be a self referencing relationship like the Employees table from Northwind. Then you set the primary key as DataKeyName and the foreign key field as ParentDataKeyName - this way the control will now exactly how to build the hierarchy.
    Here is a sample data:

    ID     ParentID     wbs1            wbs2     wbs3    Name                                                               PreConDate     DaysSincePrecon
     1            0            2009.0257                 
     2            1            2009.0257    ESTR.1            
     3            2            2009.0257    ESTR.1  U0001   31 Drakestown Road - Main Project       08/04/2010        1147
     4            1            2009.0257    LEED.1            
     5            4            2009.0257    LEED.1  U0001   31 Drakestown Road - Main Project       08/04/2010        1147
     6            0            2010.0662                 
     7            6            2010.0662    GRES.1            
     8            7            2010.0662    GRES.1  U0001   102 Creekview Drive                                  05/24/2013        123
     9            7            2010.0662    GRES.1  U0002   170E Monmouth Street                             05/24/2013        123

    More information on the treelist structure can also be found in this help topic:

    Best Regards,
    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 the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top