Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Parent Down Tree-Grid

    Hi Isomorphic,

    I'm trying to figure out how to use the TreeGrid to suit my purposes.

    The documentation and showcase provide plenty of examples of a TreeGrid arranged where the tree is bottom-up, where the leaves have references to a single parent object.
    I'm looking for examples where the tree is top-down instead.

    I have a hierarchy I want to represent where each node has a list of multiple children, but it is actually possible for a child to have multiple parents.

    The following example looks promising. In particular the TreeGrid is bound to with a Datasource provided by XML, and is loaded on demand.
    Could you provide an example that is top-down instead of bottom-up.
    http://www.smartclient.com/smartgwt/showcase/#tree_databinding_ondemand

    My problem with this example is that the entire hierarchy needs to be solved at display time, and it doesn't show how to connect it to a datasource: http://www.smartclient.com/smartgwt/showcase/#tree_databinding_children_arrays

    Thanks,
    Walker

    #2
    We're not really sure what you have in mind with "top-down" - as you noted, a tree can be constructed as a series of Arrays of child nodes, but you want load on demand, which obviously doesn't work this way.

    For load on demand, the client needs a way to pass criteria to the server to request children, and it does this by passing it's nodeID as criteria again the parentId field. To read more about this process, take a look at the Tree DataBinding overview.

    If you have some alternative protocol in mind, you'll need to be specific about how it might work. Also note, if you don't have unique IDs for your nodes as is required to achieve load on demand, you can always synthesize unique IDs using whatever information identifies nodes in your system (perhaps it's a path similar to a filesystem path, for example). This also is covered in the Tree DataBinding overview linked above.

    Comment


      #3
      Hi Walker,
      Originally posted by wbarnett View Post
      I have a hierarchy I want to represent where each node has a list of multiple children, but it is actually possible for a child to have multiple parents.
      This does not seem to be a tree data structure, but more of a mesh, perhaps with some additional rules on parent-level < child-level or similar.

      Perhaps you can transform this to an artificial tree on the DB-level and present this tree as a view to SmartGWT?

      Best regards
      Blama

      Comment


        #4
        Agreed.
        Technically speaking I'm trying to represent a directed graph in a tree view representation with some root node(s).

        I'm referring specifically to the following example in the Showcase: Load on Demand

        This is a "client-only" DataSource that specifically states in the description:
        Begin opening folders and note the prompt which briefly appears during server fetches.

        DataBound Trees support load on demand. When a folder is opened for the first time, the tree asks the server for the children of the node just opened.
        In this example, The children nodes use the "ReportsTo" attribute to refer to their parent node, i.e. Ralph, Tammy, Carol, Gene, Rogine, Abigale, John, Rui, Kirill, Joan, and Tamara all report to Charles. Bhushan, Besty, Francine, Amanda, Fa, and Chase all report to Ralph.

        Is it possible to modify this example, such that the parent node has a "ResponsibleFor" attribute providing a list of children identities? i.e. Charles is responsible for Ralph, Tammy, Carol, Gene, Rogine, Abigale, John, Rui, Kirill, Joan, and Tamara. Ralph is responsible for Bhushan, Besty, Francine, Amanda, Fa, and Chase.

        For instance if the xml for Ralph had something like:
        Code:
        <EmployeeId>192</EmployeeId>
        <EmployerOf>
        <item>295</item>
        <item>294</item>
        <item>293</item>
        <item>292</item>
        <item>291</item>
        <item>290</item>
        </EmployerOf>
        As I said, I have been digging through the documentation. I'm at the point, where I just want to see the XML Load on Demand example linked above, where the employer has a list of employees and Charles is the root node.

        If it's not possible, it's not possible.

        Thanks,
        Walker

        Comment


          #5
          Hi Walker,

          IMO it does not matter if the path is child->parent or parent->child. You can always translate the latter to c->p with SQL or XLST or whatever before handing it to SmartGWT.

          But, you'd have entries c1->p1 and c1->p2 in your data which will give you errors in SmartGWT (I assume).
          You could transform your data to c1p1->p1 and c1p2->p2, though. This way, from SmartGWT's point of view, the data should look like a tree instead of a directed graph.

          Best regards
          Blama

          Comment


            #6
            As covered in the docs, the ResultTree loads children for a node by creating criteria of the form:

            Code:
               { parentIdField : "idOfParent" }
            Since you're being passed the id of the parent node that is loading children, you will be able to look up the parent node, and use a list of children stored in that node to find the children instead. So you should be able to fulfill these requests.

            Just be sure that when you return the data, you actually populate a parentIdField, since the client-side system expects this to actually exist.

            Comment

            Working...
            X