PDA

View Full Version : [FIXED] Collapsing selected TreeItem calls deselect(item) when caching=false



negge
23 Jun 2008, 3:05 PM
If you have treeBinder.setCaching(false) and select a node, then collapse it, the node is incorrectly deselected. This is because the TreeItem posts an Events.Remove where treeEvent.item=this (the parent) and treeEvent.child=item (the node to remove). The AbstractSelectionModel then checks if ComponenetEvent.item is selected (it is) and then deselects it. The fix is to always have treeEvent.item be the TreeItem you are acting on.

A patch:


--- user/src/com/extjs/gxt/ui/client/event/TreeEvent.java (revision 508)
+++ user/src/com/extjs/gxt/ui/client/event/TreeEvent.java (working copy)
@@ -27,9 +27,9 @@
public Tree tree;

/**
- * The child item.
+ * The parent item.
*/
- public TreeItem child;
+ public TreeItem parent;

/**
* Creates a new tree event.
Index: user/src/com/extjs/gxt/ui/client/widget/tree/TreeItem.java
===================================================================
--- user/src/com/extjs/gxt/ui/client/widget/tree/TreeItem.java (revision 508)
+++ user/src/com/extjs/gxt/ui/client/widget/tree/TreeItem.java (working copy)
@@ -38,8 +38,8 @@
* <div>Fires before a item is removed. Listeners can set the <code>doit</code>
* field to <code>false</code> to cancel the action.</div>
* <ul>
- * <li>item : this</li>
- * <li>child : the item being removed</li>
+ * <li>parent : this</li>
+ * <li>item : the item being removed</li>
* </ul>
* </dd>
*
@@ -62,8 +62,8 @@
* <dd><b>Add</b> : TreeEvent(item, child, index)<br>
* <div>Fires after a item has been added or inserted.</div>
* <ul>
- * <li>item : this</li>
- * <li>child : the item that was added</li>
+ * <li>parent : this</li>
+ * <li>item : the item that was added</li>
* <li>index : the index at which the item will be added</li>
* </ul>
* </dd>
@@ -71,8 +71,8 @@
* <dd><b>Remove</b> : TreeEvent(item, child)<br>
* <div>Fires after a item has been removed.</div>
* <ul>
- * <li>item : this</li>
- * <li>child : the item being removed</li>
+ * <li>parent : this</li>
+ * <li>item : the item being removed</li>
* </ul>
* </dd>
*
@@ -150,8 +150,8 @@
*/
public void add(TreeItem item, int index) {
TreeEvent te = new TreeEvent(tree);
- te.item = this;
- te.child = item;
+ te.parent = this;
+ te.item = item;
te.index = index;
if (fireEvent(Events.BeforeAdd, te)) {
item.parentItem = this;
@@ -378,8 +378,8 @@
return;
}
TreeEvent te = new TreeEvent(tree);
- te.item = this;
- te.child = item;
+ te.parent = this;
+ te.item = item;
if (fireEvent(Events.BeforeRemove, te)) {
children.remove(item);
tree.unregisterItem(item);Nathan

negge
24 Jun 2008, 8:24 AM
Fix is in SVN.