Hello,

Programmatic change of selection state of node in TreeVirtual does not
select the appropriate row in the table. The following patch can eliminate
the problem.

            qx.Class.patch(qx.ui.treevirtual.SimpleTreeDataModel,
               
qx.Mixin.define("patch.qx.ui.treevirtual.SimpleTreeDataModel",
                {
                    members :
                    {
                        setState : function(nodeReference, attributes)
                        {
                          var nodeId, node;

                          if (typeof(nodeReference) == "object")
                          {
                            node = nodeReference;
                            nodeId = node.nodeId;
                          }
                          else if (typeof(nodeReference) == "number")
                          {
                            nodeId = nodeReference;
                            node = this._nodeArr[nodeId];
                          }
                          else
                          {
                            throw new Error("Expected node object or node
id");
                          }

                          for (var attribute in attributes)
                          {
                            // Do any attribute-specific processing
                            switch(attribute)
                            {
                            case "bSelected":
                                var nRowIndex =
this.getRowFromNodeId(nodeId);
                                var selectionModel =
this.getTree().getSelectionModel();
                                var bChangeSelection = (typeof(nRowIndex)
=== "number"
                                    && this.getTree().getSelectionMode() !=
qx.ui.treevirtual.TreeVirtual.SelectionMode.NONE);
                              // The selected state is changing. Keep track
of what is selected
                              if (attributes[attribute])
                              {
                                this._selections[nodeId] = true;
                                  // Add selection range for node
                                  if (bChangeSelection && !
selectionModel.isSelectedIndex(nRowIndex)) {
                                     
selectionModel.setSelectionInterval(nRowIndex, nRowIndex);
                                  }
                              }
                              else
                              {
                                delete this._selections[nodeId];
                                  // Delete selection range for node
                                  if (bChangeSelection &&
selectionModel.isSelectedIndex(nRowIndex)) {
                                     
selectionModel.removeSelectionInterval(nRowIndex, nRowIndex);
                                  }
                              }
                              break;

                            case "bOpened":
                              // Don't do anything if the requested state is
the same as the
                              // current state.
                              if (attributes[attribute] == node.bOpened)
                              {
                                break;
                              }

                              // Get the tree to which this data model is
attached
                              var tree = this.__tree;

                              // Are we opening or closing?
                              if (node.bOpened)
                              {
                                // We're closing.  If there are listeners,
generate a treeClose
                                // event.
                                tree.createDispatchDataEvent("treeClose",
node);
                              }
                              else
                              {
                                // We're opening.  Are there any children?
                                if (node.children.length > 0)
                                {
                                  // Yup.  If there any listeners, generate
a "treeOpenWithContent"
                                  // event.
                                 
tree.createDispatchDataEvent("treeOpenWithContent", node);
                                }
                                else
                                {
                                  // No children.  If there are listeners,
generate a
                                  // "treeOpenWhileEmpty" event.
                                 
tree.createDispatchDataEvent("treeOpenWhileEmpty", node);
                                }
                              }

                              // Event handler may have modified the opened
state.  Check before
                              // toggling.
                              if (!node.bHideOpenClose)
                              {
                                // It's still boolean.  Toggle the state
                                node.bOpened = !node.bOpened;

                                // Clear the old selections in the tree
                                tree.getSelectionModel()._clearSelection();
                              }

                              // Re-render the row data since formerly
visible rows may now be
                              // invisible, or vice versa.
                              this.setData();
                              break;

                            default:
                              // no attribute-specific processing required
                              break;
                            }

                            // Set the new attribute value
                            node[attribute] = attributes[attribute];
                          }
                        }
                    }
                })
            );


Best regards,
Denis

-- 
View this message in context: 
http://www.nabble.com/Patch-that-changes-selected-rows-in-table-when-selection-state-of-node-of-TreeVirtual-is-changed-tp17083227p17083227.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to