Announcement

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

    treegrid and parentid

    Hello,

    I am using tree grid and can get back my initial set of tree data. It loads fine.

    I would like to open JUST the data I have brought back. I DO NOT want to have some queries fired off for parentids when I expand the nodes I have gotten. How can I control these "extra queries" that are running?

    For example, the following has a number of mysql queries for each node that is found looking for parentid. How can I turn that behavior off while I expand just what getData() gave back?

    Evan

    public void onDataArrived(com.smartgwt.client.widgets.tree.events.DataArrivedEvent event) {
    // the following does expand all the nodes, however it also forces a new query on each leaf node!! not what we wanted
    Tree t = treeGrid.getData();
    TreeNode nodes[] = t.getDescendants();
    for (TreeNode n : nodes) {
    // make leaves not be folders so don't expand
    int numchildren = n.getAttributeAsInt("numchildren");
    if (numchildren == 0) n.setIsFolder(false);
    else t.openFolder(n);
    }

    #2
    If you open a folder that is not loaded, it needs to query the server.

    If you didn't mean for that node to be treated as a folder, see the Tree DataBinding overview, paying attention to isFolder and related properties.

    If you didn't mean to open an unloaded folder, you can use Tree.getLoadState() to avoid this.

    Comment


      #3
      Nodes are loaded

      Hello,

      I am using
      SmartClient Version: v8.3p_2013-04-19/PowerEdition Deployment (built 2013-04-19)
      With GWT 2.5.1

      My treeGrid.getData() is returning all the nodes I wish to see, so they are already loaded. Or should be. I can't set anything on the node to say "it is loaded do not go get data". Which is what I would like. So then I want to "open any of the nodes" that I have brought back and "do not go out and fetch anything".

      So what are the settings for this case?

      Evan

      Comment


        #4
        Have you taken a look at the Tree DataBinding overview and the JavaDoc for the properties it references? That's where you'll find out how to control what happens with these nodes, including controlling distinctions between whether they are just nodes, or folders that are empty (hence should not cause a fetch).

        Comment


          #5
          hi

          Yes I have looked at the documentation, several times.

          And I see the distinctions.

          I guess the difference is I have a tree which is complete on the first load BUT then for leaf nodes I would like them to be on demand. So the internal nodes are not on demand and the leaf nodes are. Or even the internal nodes could be on demand AFTER the initial tree is loaded and opened.

          Evan

          Comment


            #6
            Sorry, not following..

            Folders can load children, leaf nodes do not have children at all, so there is no notion of them loading or not loading on demand..

            Maybe you can show a little ascii-art diagram of the phases of tree loading you are hoping for.

            Comment


              #7
              Tree vs ResultTree

              So currently I am on demand and have a ResultTree

              I use .setDataSource on my resultTree, but the tree type does not have such a method. How does one set the data source on the tree? Can I change to a demand form tree after loading as a tree?

              Evan

              Comment


                #8
                There is no need to setDataSource on the ResultTree because it already has the DataSource you specified on the TreeGrid that created it.

                This is really really not making sense now. We suggest you start over with your explanation of what you want, and again, a little ascii-art diagram would go a long way toward explaining what you have in mind.

                Comment


                  #9
                  what i want :-)

                  Step 1.
                  I have a custom query that brings back a fully legal tree which I can display. And I have done this, simple query that brings back the portion of a massive tree that matches a string criteria I have.

                  * I iterate over the nodes and set those that have no children as "n.setIsFolder(false)". And I set the others to
                  t.openFolder(n) Though I think the openFolder setting may force another query which I don't want.

                  Step 2.
                  Now show this smallish tree (which is a subset of our big big big tree). I have to do a subset as there does not seem to be paging in trees and I can't load such a large tree.

                  Step 3.
                  Allow a user to browse the tree with scroll or expand/collapse.

                  Step 4.
                  If they get to a folder that has no children then request a load of all the children below that node.

                  Comment


                    #10
                    In Step 1, what are you hoping is going to happen as a result of openFolder()? An open folder shows it's children. If the children has not been loaded, there will be a fetch. The only other possibility is having no children.

                    Comment


                      #11
                      hmm

                      I want to show what I currently have loaded. However I want to be able to force a reload of any node, bringing back its children (existing and perhaps others) with a method call. Then I could add a button on the tree that is in effect ("load me").

                      Basically put the parentid call in my control.

                      Sounds like I need to be in tree mode initially and then add data to the tree when I want to?

                      Evan

                      Comment


                        #12
                        Are you saying that these folders *actually have some children loaded* and you want to show those, but at some later time you might want to show some *additional* children under the same node?

                        If so, there's reloadChildren().

                        Comment


                          #13
                          yes

                          Yes, reloadChildren sounds like what I want.

                          Let me see if I can work something up with this.

                          Thanks!!!

                          Comment


                            #14
                            hmm

                            Hello,

                            Well ...

                            So I wanted to in my first step load this "tree subset" of my "big big tree".

                            If I use the "tree" type and set the data source on the treeGrid it draws back the entire tree. And this seems to happen before
                            I even call my treeGrid.fetchData with a criteria which is what I had been doing when I had a result tree.

                            Ideas?

                            The first step before a loadChildren is to load the sub tree using a criteria. So lets focus on that, the step 1.

                            Evan

                            Comment


                              #15
                              Why are you directly using a Tree at all?

                              You would generally just start with a call to fetchData(), and control which nodes are folders or not using the properties documented in the Tree Data Binding overview.

                              Comment

                              Working...
                              X