Ticket #638 (closed defect: fixed)

Opened 3 years ago

Last modified 18 months ago

Adding child to tree using RPC control causes double-addition

Reported by: lcampagn@… Owned by: ilia
Priority: highest Milestone:
Component: Widgets Version: 0.3
Severity: major Keywords:
Cc:

Description

I've got an RPC controlled tree based off of this example http://archive.dojotoolkit.org/nightly/tests/widget/tree/test_Tree_7.html only running a real database backend. The problem is that if I create a child on a node that has not yet been expanded, I see the created node twice--once from when it is initially created, and another from when the node is expanded.

Using nightly for 04/20

Change History

Changed 2 years ago by m.zdila@…

  • priority changed from normal to highest
  • version changed from 0.2 to 0.3
  • severity changed from normal to major
  • milestone set to 0.3.1

this problem is still there in dojo 0.3.1 !

cause: before adding a newly created node to its parent, the parent is expanded for the first time and therefore all its children are loaded from server already including newly created node. This cause node duplication.

Here is a small "patch" that has helped me (please add it to new milestone after your additional corretions): replaced method in TreeLoadingController?.js:

doCreateChild: function(parent, index, data, callObj, callFunc) {

/* load nodes into newParent in sync mode, if needed, first */ if (parent.state == parent.loadStates.UNCHECKED) {

this.loadRemote(parent, true); parent.expand(); // there is nothing to return

} else {

return dojo.widget.TreeBasicController?.prototype.doCreateChild.apply(this, arguments);

}

}

Changed 2 years ago by bill

  • owner changed from anonymous to ilia
  • milestone changed from 0.3.1 to 0.4

Ilia, what do you think? I'm not sure if this is a bug or not.

Changed 2 years ago by m.zdila@…

uh! I've introduced a new bug with my "patch". Therefore a new "patch":

doCreateChild: function(parent, index, data, callObj, callFunc) {
	/* load nodes into newParent in sync mode, if needed, first */
	if (parent.state == parent.loadStates.UNCHECKED) {
		this.loadRemote(parent, true);
		this.expand(parent);
	
		if (callFunc) {
			callFunc.apply(callObj, [/*newChild*/]);
		}
		// there is nothing to return :-(
	} else {
		return dojo.widget.TreeBasicController.prototype.doCreateChild.apply(this, arguments);
	}
}

Disadvantage is that there is no new node to return if parent loads it's children and no new node to call callback fn with. I see 2 methods to workaround this:

1. when loadRemote, do not load newly created node (in this case there would have to be some parameter to loadRemote denoting the new node)

2. load also newly created node, but don't create it with ...doCreateChild.apply

Changed 2 years ago by ilia

  • status changed from new to closed
  • resolution set to fixed

Patch accepted into stable Tree. TreeV3 does not seem to have such problem

Changed 18 months ago by anonymous

  • milestone deleted

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.