Announcement

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

    Checkbox-style TreeGrid with initial partially selected state

    SmartGWT version 2.4
    GWT version 2.1.0

    Great product!

    I have created a TreeGrid with selection appearance CHECKBOX

    // relevant code
    TreeGrid treeGrid = new TreeGrid();
    treeGrid.setShowPartialSelection(true);
    treeGrid.setSelectionProperty("selected");
    treeGrid.setShowRoot(false);

    Tree tree = new Tree();
    tree.setModelType(TreeModelType.PARENT);
    tree.setIdField("id");
    tree.setNameProperty("name");
    tree.setParentIdField("parent");
    tree.setOpenProperty("isOpen");
    tree.setShowRoot(false);

    // create a bunch of TreeNodes in treeNodeList
    // with the correct attributes to form a tree
    // this part works.

    List<TreeNode> treeNodeList = new ArrayList<TreeNode>();
    // add nodes to list

    TreeNode[] nodes = new TreeNode[treeNodeList.size()];
    treeNodeList.toArray(nodes);

    // create and configure TreeNode sectionNode
    tree.setRoot(sectionNode); // root created elsewhere & not displayed
    tree.setData(nodes);
    treeGrid.setData(tree);


    The TreeNodes display correctly and respond appropriately when there is a partial selection due to user interaction.

    However, if the initial state of the tree includes a partially selected tree, the parent node shows fully selected instead of partially selected.

    Is there a way to work around this in the currently released version?

    Thanks.

    #2
    We'd need to see a runnable test case to confirm this as a bug vs a usage issue, but if it were a real bug, opening and closing folders would probably fix it.

    Comment


      #3
      Hi,
      I'm using a TreeGrid with external datasource in JSON format.
      When I send a the data I also specify if some of them are folders or not with the 'isFolder' property.

      The nodes that have 'isFolder' set to false, are the only ones how have the property 'isSelected', according to what should be its default state.

      The main problem is that after load the data, the folders didn't get the partial state unless the user changes some checked state from the nodes.

      There is any way to fix this in my code, or it is a SmartClient problem... ?

      Code:
      tg = new TreeGrid();
      tg.setDataSource(tgDS.getInstance());
      tg.setAutoFetchData(false);
      tg.setAutoFetchAsFilter(true);
      tg.setShowHeader(false);
      tg.setNodeIcon("node.png");
      tg.setSelectionAppearance(SelectionAppearance.CHECKBOX);
      tg.setShowSelectedStyle(false);  
      tg.setShowPartialSelection(true);  
      tg.setCascadeSelection(true);
      tg.setSelectionProperty("isSelected");
      Thanks in advance.

      Comment


        #4
        We see the problem and are working on a fix in the framework. We'll update this thread when we have a resolution.

        Comment


          #5
          This should be resolved in nightly builds going forward. Please let us know if you continue to see it

          Regards
          Isomorphic Software

          Comment


            #6
            With SmartGWT 2011-09-21 LGPL 2.5.x nightly:

            The partial selection appears correctly.

            Since onSelectionChanged is called on data arrived, I removed my onDataArrived code (this is just a comment).

            But the problem comes with now onSelectionChanged is called more often than needed. I think it is called for every item, on each redraw; for example: when a folder is opened, or on every selection change,
            it is called for each item in the tree.

            I think this also must be fixed...

            Thanks for all.

            Pau
            Last edited by prodrigestivill; 21 Sep 2011, 05:26.

            Comment


              #7
              See the docs for addSelectionChangedHandler() - the selectionUpdated event fires less frequently and is what we'd recommend for any kind of expensive operation you need to do in response to selection changes.

              Comment


                #8
                Originally posted by prodrigestivill
                With SmartGWT 2011-09-21 LGPL 2.5.x nightly:
                [...]
                onSelectionChanged is called more often than needed. I think it is called for every item, on each redraw.
                [...]
                I think this also must be fixed...
                Originally posted by Isomorphic
                See the docs for addSelectionChangedHandler() - the selectionUpdated event fires less frequently and is what we'd recommend for any kind of expensive operation you need to do in response to selection changes.
                What I'm saying is that now onSelectionChanged is called on each redraw independently of if any selection is changed or not...

                So I assume you are working into fix this bug?

                Thanks in advance...

                Comment


                  #9
                  We are not seeing this effect per-redraw() where by redraw we mean literally the method call redraw(). What do you mean by "redraw" and how can we reproduce spurious selectionChanged notifications?

                  Comment


                    #10
                    Originally posted by Isomorphic
                    We are not seeing this effect per-redraw() where by redraw we mean literally the method call redraw(). What do you mean by "redraw" and how can we reproduce spurious selectionChanged notifications?
                    Originally posted by prodrigestivill
                    With SmartGWT 2011-09-21 LGPL 2.5.x nightly:
                    when a folder is opened, or on every selection change,
                    it is called for each item in the tree.
                    An example:
                    onSelectionChanged is called for every tree node with it's current state in this cases:
                    -each time a folder is opened or closed.
                    -each time a a selection change.
                    -and maybe each time is added a new node (this is not fully tested, but at the begining it is called too many times)

                    Comment


                      #11
                      We've added some code that should ameliorate this situation. Please try the next nightly build and let us know if you continue to see problems with the selectionChanged notification being fired too often.

                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        Originally posted by Isomorphic
                        We've added some code that should ameliorate this situation. Please try the next nightly build and let us know if you continue to see problems with the selectionChanged notification being fired too often.
                        With 2.5.x nightly 2011-09-23:

                        The unneeded calls to onSelectionChanged are fixed.

                        But now the UI check-box state for the folders is inconsistent.

                        The state fully checked and partially checked for folders didn't match with the states of its content.

                        Hopefully next fix will be the definitive,

                        Thanks in advance.

                        Pau

                        Comment


                          #13
                          Our apologies for the inconvenience - we've made some further changes to resolve this and believe it should all be working as of the current codebase (so next nightly build).

                          The behavior for cascading selection, coupled with load data on demand, and specifying selection via the selected property directly on the data (on the server) is as follows:

                          When data arrives from the server, (assume children of some loaded parent node), the system will ensure cascading selection state is set consistently across the tree:
                          - if the parent is selected, all the children are automatically marked as selected as well.
                          - if the parent is unselected, if all children are marked as selected, the parent will also be marked as selected. If some children are marked as selected it will be marked as partially selected.

                          The selectionChanged notification will not fire for any nodes for cascading selection synchronization that occurs simply due to data arriving.


                          If the user explicitly selects or deselects a node, selection will "cascade" - all children will become selected or deselected as appropriate, and parents will be marked as selected, deselected or partially selected depending depending on what set of their children are now selected.

                          In this case selectionChanged notification will fire for the node the user explicitly changed, and for any nodes whose selection state was modified due to cascading selection.

                          Regards
                          Isomorphic Software

                          Comment


                            #14
                            Compiled with 2011-09-26 2.5.x nightly build and it work everything as says in documentation...

                            So all bugs I found are fixed. :)

                            Thanks for all...

                            Pau

                            Comment

                            Working...
                            X