Loading a Treeview from database, infinite sub nodes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    Loading a Treeview from database, infinite sub nodes

    Hi

    We have the below details:

    Order_Base
    CustomerNo, OrderNo, OrderItemNo.... .

    Order_Detail
    OrderItemNo, ParentItemNo, Desc......

    Order_Detail.Pa rentItemNo is a FK for Order_Base.Orde rItemNo

    There is also the ability for Order_Detail.Pa rentItemNo to relate to another
    higher level record of Order_Detail.Pa rentItemNo

    (dont blame me for the database design)

    We want to display these details in a Tree View:

    1Order_Base
    2 Order_Detail which relates to Order_Base (Order_Detail.P arentItemNo =
    Order_Base.Orde rItemNo)
    3 Order_Detail which relates to parent record Order_Detail
    (Order_Detail.P arentItemNo = Order_Detail.Or derItemNo)
    4 Order_Detail which relates to parent record Order_Detail
    (Order_Detail.P arentItemNo = Order_Detail.Or derItemNo)
    5 Order_Detail which relates to parent record Order_Detail
    (Order_Detail.P arentItemNo = Order_Detail.Or derItemNo)
    6 Order_Detail which relates to parent record Order_Detail
    (Order_Detail.P arentItemNo = Order_Detail.Or derItemNo)

    The problem I have is that the quantity of sub items could go on forever,
    the sql select statement for level 3 and beyond should be identical with
    only the parent variable changed.

    I am having problems creating re-usable code so that I can loop though them
    past stage 2, my code currenlty has selected all items at level 1 and two
    and they are all there fine. but how do I continue from here?

    Any help would be very much appreicated

    Thanks
    B


  • Phill W.

    #2
    Re: Loading a Treeview from database, infinite sub nodes

    Ben wrote:
    The problem I have is that the quantity of sub items could go on forever,
    the sql select statement for level 3 and beyond should be identical with
    only the parent variable changed.
    >
    I am having problems creating re-usable code so that I can loop though them
    past stage 2, my code currenlty has selected all items at level 1 and two
    and they are all there fine. but how do I continue from here?
    Let your User do the looping ....

    If you start unravelling things to this sort of depth all in one go, the
    vast majority of users are going to die of boredom.

    If they want to drill down that far, by all means let them, and just
    expand each level of the tree as they go.

    HTH,
    Phill W.

    Comment

    • Ben

      #3
      Re: Loading a Treeview from database, infinite sub nodes

      Thanks Phill

      I sorted out of couple of levels of nodes and, as you say, started to die of
      boredom!

      How can I add the expansion pluses to each item to indicate to the user that
      there maybe something below (before I have loaded them).

      Thanks
      B

      "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
      news:er4opq$pao $1@south.jnrs.j a.net...
      Ben wrote:
      >
      >The problem I have is that the quantity of sub items could go on forever,
      >the sql select statement for level 3 and beyond should be identical with
      >only the parent variable changed.
      >>
      >I am having problems creating re-usable code so that I can loop though
      >them past stage 2, my code currenlty has selected all items at level 1
      >and two and they are all there fine. but how do I continue from here?
      >
      Let your User do the looping ....
      >
      If you start unravelling things to this sort of depth all in one go, the
      vast majority of users are going to die of boredom.
      >
      If they want to drill down that far, by all means let them, and just
      expand each level of the tree as they go.
      >
      HTH,
      Phill W.

      Comment

      • Ben

        #4
        Re: Loading a Treeview from database, infinite sub nodes

        Actually Scap that, I will load the window with 2 levels and then load a
        subsequent one level on each expansion.

        Thanks for your help.

        B
        "Ben" <Ben@Newsgroups .microsoft.comw rote in message
        news:%23IMGkDfU HHA.3592@TK2MSF TNGP06.phx.gbl. ..
        Thanks Phill
        >
        I sorted out of couple of levels of nodes and, as you say, started to die
        of boredom!
        >
        How can I add the expansion pluses to each item to indicate to the user
        that there maybe something below (before I have loaded them).
        >
        Thanks
        B
        >
        "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
        news:er4opq$pao $1@south.jnrs.j a.net...
        >Ben wrote:
        >>
        >>The problem I have is that the quantity of sub items could go on
        >>forever, the sql select statement for level 3 and beyond should be
        >>identical with only the parent variable changed.
        >>>
        >>I am having problems creating re-usable code so that I can loop though
        >>them past stage 2, my code currenlty has selected all items at level 1
        >>and two and they are all there fine. but how do I continue from here?
        >>
        >Let your User do the looping ....
        >>
        >If you start unravelling things to this sort of depth all in one go, the
        >vast majority of users are going to die of boredom.
        >>
        >If they want to drill down that far, by all means let them, and just
        >expand each level of the tree as they go.
        >>
        >HTH,
        > Phill W.
        >
        >

        Comment

        • Lloyd Sheen

          #5
          Re: Loading a Treeview from database, infinite sub nodes

          All you need to do is add a "dummy" node. That node will ensure that the
          GUI shows the expand "+". Then when you get an expand event you check and
          if the only node existing is the "dummy" node then you delete the "dummy"
          node and then populate the expanded node. If there are no items to be
          populated your user will see an empty tree node.

          Easy to do and will make you app much faster.

          Lloyd Sheen
          "Ben" <Ben@Newsgroups .microsoft.comw rote in message
          news:%23IMGkDfU HHA.3592@TK2MSF TNGP06.phx.gbl. ..
          Thanks Phill
          >
          I sorted out of couple of levels of nodes and, as you say, started to die
          of boredom!
          >
          How can I add the expansion pluses to each item to indicate to the user
          that there maybe something below (before I have loaded them).
          >
          Thanks
          B
          >
          "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
          news:er4opq$pao $1@south.jnrs.j a.net...
          >Ben wrote:
          >>
          >>The problem I have is that the quantity of sub items could go on
          >>forever, the sql select statement for level 3 and beyond should be
          >>identical with only the parent variable changed.
          >>>
          >>I am having problems creating re-usable code so that I can loop though
          >>them past stage 2, my code currenlty has selected all items at level 1
          >>and two and they are all there fine. but how do I continue from here?
          >>
          >Let your User do the looping ....
          >>
          >If you start unravelling things to this sort of depth all in one go, the
          >vast majority of users are going to die of boredom.
          >>
          >If they want to drill down that far, by all means let them, and just
          >expand each level of the tree as they go.
          >>
          >HTH,
          > Phill W.
          >
          >

          Comment

          Working...