Announcement

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

    TreeGrid and Tree

    Hi,

    I am having problems with my TreeGrid since updating to SmartGWT 2.0, and couldn't find any thread with the same problem.
    In my application I have a TreeGrid showing the contents of a
    com.smartgwt.client.widgets.tree.Tree
    If the tree needed more data, it used GWT-RPC and displayed the data in the TreeGrid. This does not seem to be possible anymore.
    I read http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/TreeDataBinding.html and what I understand from this document is:
    If I use a Tree Object as parameter in the Method setData() from the TreeGrid, then the TreeGrid is only able to show what is already loaded into the tree, but nothing that adds later?
    At the moment I only load the root node and add it to the tree. Then I initialize the TreeGrid and use this tree when calling setData().
    Later on, when more nodes a loaded into the tree, they are not displayed, even though when I call
    Code:
    System.out.println(treeGrid.getTree().getChildren(root).length);
    it prints the correct amount of children. So my question is, if there is a way to use a Tree as a DataSource for a TreeGrid, and also show nodes, that are loaded into the tree after creating the TreeGrid?

    Thanks in advance for your answers. If necessary, I'll answer any questions as quick as possible, but you have to be aware I'm in the timezone of Germany.

    #2
    There was a problem with adding new nodes to trees, which should already be resolved I'd you try a nightly build. Please confirm.

    Comment


      #3
      Hi and Thank You for the quick answer. At the moment I'm experiencing a problem where I cannot find out what the reason for it is. This problems occurs with SmartGWT 1.3, 2.0 and the build from January 6th. I think I'm doing something wrong, but there are no error messages at all.
      What I'm doing is:
      I have a subclass from TreeGrid. I haven't overriden any methods. All I do is set properties for the Tree in the constructor like this:
      Code:
      public MyTreeGrid(int contentId) { // this class extends TreeGrid
              setAlternateRecordStyles(true);
              setAnimateFolders(true);
              setAutoFitData(Autofit.BOTH);
              // and so on.
              // initialize the fields
              Tree tree = MyTrees.get(contentId);
              setData(tree);
              setFields(name, number, property);
      This TreeGrid will be in a pane of a tab later on, like this:
      Code:
              Tab tab = new Tab();
              tab.setTitle(titleForId(contentId));
              Button test1 = new Button("Test_1");
              Button test2 = new Button("Test_2");
              MyTreeGrid gui = new MyTreeGrid(contentId);
              VLayout buttons = new VLayout();
              buttons.setMembers(test1, test2);
              HLayout mainLayout = new HLayout();
              mainLayout.setMembers(buttons, gui);
              tab.setPane(mainLayout);
      Now there are 2 different possibilities. If i delete the following code from the top:
      Code:
      setData(tree);
      then I see my tab with the two buttons and a TreeGrid. From the TreeGrid I see columns (header row), but no data --> which is obviously correct behaviour, because I did not call the setData() method.
      The second possibility is, that I leave the setData(tree); untouched and run the code. Then I see an empty tab.
      I double checked with different console outputs that the tree was loaded correctly and held the data to be shown. As mentioned there are no errors or warnings at all. Eventhough the tab is blank, I can find the buttons with FireBug.
      The Buttons:
      Code:
      <td class="button" nowrap="true" valign="center" align="center" onfocus="isc_OID_12.$47()" tabindex="-1" style="padding-top: 0px; padding-bottom: 0px;">Test_1</td>
      Also I can find a ListGrid and the header for it with FireBug:
      Code:
      <div id="isc_12" class="listGrid" onscroll="return isc_OID_15.$lh()" style="overflow: hidden; position: absolute; left: 0px; top: 0px; width: 1128px; height: 276px; z-index: 200342; -moz-box-sizing: border-box;" eventproxy="isc_OID_15">
      <div id="isc_13" style="position: relative; visibility: inherit; z-index: 200342; cursor: default;" eventproxy="isc_OID_15">
      <div id="isc_14" class="headerBar" onscroll="return isc_Toolbar_19.$lh()" style="padding: 0px; overflow: hidden; position: absolute; left: 0px; top: 0px; width: 1126px; height: 23px; z-index: 200324; -moz-box-sizing: border-box; outline-offset: -1px;" tabindex="-1" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_Toolbar_19,true);" onfocus="if(event.target!=this)return;isc.EH.focusInCanvas(isc_Toolbar_19,true);" eventproxy="isc_Toolbar_19">
      <div id="isc_15" style="position: relative; visibility: inherit; z-index: 200324; cursor: default;" eventproxy="isc_Toolbar_19">
      <div id="isc_16" onscroll="return isc_ImgButton_20.$lh()" style="overflow: hidden; position: absolute; left: 0px; top: 0px; width: 438px; height: 23px; z-index: 200361; -moz-box-sizing: border-box; outline-offset: 0px;" tabindex="-1" onblur="if(window.isc)isc.EH.blurFocusCanvas(isc_ImgButton_20_label,true);" onfocus="if(event.target!=this)return;isc.EH.focusInCanvas(isc_ImgButton_20_label,true);" eventproxy="isc_ImgButton_20">
      <div id="isc_17" style="position: relative; visibility: inherit; z-index: 200361; cursor: default;" eventproxy="isc_ImgButton_20">
      <table height="100%" width="100%" cellspacing="0" cellpadding="0" style="overflow: hidden; table-layout: fixed;">
      <tbody>
      <tr>
      <td class="headerTitle" nowrap="true" valign="center" align="left" onfocus="isc_ImgButton_20_label.$47()" tabindex="-1" style="padding-top: 0px; padding-bottom: 0px;">Name</td>
      </tr>
      </tbody>
      </table>
      </div>
      </div>
      I'm basically rewriting an application I have build with GWT 1.7 and SmartGWT 1.3, now with GWT 2.0 and SmartGWT 2.0. I did not change a lot, so this is really annoying me (although I'm pretty sure it's my own fault). I would really appreciate any further advice, and apologize for my typos and grammar! I have always found solutions for my problem in this forum, hopefully it stays that way!
      Best Regards,
      jmlordo

      Comment


        #4
        No way to tell from that description, so try simplifying until it works again.

        Note that there may somehow be an error which is not being reported, so try multiple browsers.

        Comment


          #5
          Hi, thanks again once more for the answer! Now I found a significant difference in the HTML showed by the browser. This snippet is from the version where
          Code:
          setData(tree);
          is disabled:
          Code:
          <div id="isc_10" eventproxy="isc_OID_14" class="listGrid"
          	style="overflow: hidden; position: absolute; left: 110px; top: 0px; width: 1161px; height: 234px; z-index: 200324; -moz-box-sizing: border-box;"
          	onscroll="return isc_OID_14.$lh()">
          <div id="isc_11" eventproxy="isc_OID_14"
          And this snippet is from the version where
          Code:
          setData(tree);
          is enabled:
          Code:
          <div id="isc_10" eventproxy="isc_OID_14" class="listGrid"
          	style="overflow: hidden; position: absolute; left: 0px; top: -9999px; width: 1128px; height: 250px; z-index: 200324; -moz-box-sizing: border-box;"
          	onscroll="return isc_OID_14.$lh()">
          Especially look at the "top" attribute! Does this make any sense? When I create a tree and add some hardcoded nodes, and use this tree as parameter in setData(tree); everything works fine.
          If anyone knows a reason for my TreeGrid (and other GUI elements) being at position: top: -9999px, please give me a hint!
          Best regards,
          jmlordo

          Comment


            #6
            That means the component was being drawn offscreen.

            It's almost certain that a JS error is occurring and not being reported. Again, try multiple browsers to see if one can reveal the error. And, simplify into a test case.

            Comment

            Working...
            X