Dataset databinding question

3 posts, 1 answers
  1. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 19 Mar 2009 Link to this post

    I'm having trouble binding a dataset to a treeview, and am hoping to get some help.

    I have a dataset that essentially flattens a couple of relational tables (Biz Segments, Biz Units, and Facilities).

    The dataset look like:

     BizSegmentID,BizSegmentName,BizUnitID,BizUnitName,FacilityID,FaciliyName
    1,SegA,1,UnitA,1,FacilityA
    1,SegA,1,UnitA,2,FacilityB
    1,SegA,2,UnitB,3,FacilityC
    1,SegA,2,UnitB,4,FacilityD
    2,SegB,3,UnitC,5,FacilityE
    2,SegB,3,UnitC,6,FacilityF

    I want the tree to look like:

    -SegA
        --UnitA
            ---FacilityA
            ---FacilityB
        --UnitB
            ---FacilityC
            ---FacilityD
    -SegB
        --UnitC
            ---FacilityE
            ---FacilityF

    What is the best way to go about binding the tree to this type of dataset?

    Thanks in advance,
    Gene.
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 20 Mar 2009 Link to this post

    Hello Gene,

    I think RadTreeView cannot automatically bind to this type of data. What it can bound to is self referencing tables. Please check this help article for additional info.

    All the best,
    Albert
    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. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 23 Mar 2009 Link to this post

    Thanks for the response Albert.

    We ended up refactoring the DataSet into a Parent/Child structure (below) and binding to that.

    nodeID, parentID, name
    bs.1, null, SegA
    bu.1, bs.1, UnitA
    fs.1, bu.1, FacilityA
    fs.2, bu.1, FacilityB
    bs.2, null, SegB
    bu.2, bs.2, UnitB
    bu.3, bs.2, UnitC
    etc.

    The short of it is that we concatenate an "identifier" to the primarykey and use that to differentiate the different heirarchies.

    Perhaps you guys could put a couple more attibutes on the treeview to differentiate a node's type and parent type for the different branches of your tree.

    Thanks again!
    Gene
Back to Top