View Full Version : tree behavior change for dynamic loaded child nodes

29 Dec 2011, 3:21 PM
I have a tree. Root node not shown. At construct time it calls the store to load the root's children (there is 1 of them). That child has no children but is marked !leaf.

in 4.0.7
A plus appears next to the single node. When I click the plus the store is called to load the children (if any)

in 4.1
no plus appears next to it so its children never get loaded

29 Dec 2011, 3:53 PM
I have worked out why this is.

when the first child is added it is marked as phantom. And hence appendChild marks is as 'loaded'

When isExpandable is called the answer is false because isLoaded is true and it has no children.

The node is marked as phantom because I didnt supply an id for it. This is the new bit. Why a auto-id node should be 'phantom' I dont know.

29 Dec 2011, 10:15 PM
Test case code?

Phil Guerrant
30 Dec 2011, 12:14 PM
An appended phantom record is marked as "loaded" intentionally because the "loaded" field determines whether or not the proxy will attempt to load the record's children when it is expanded. Since a newly created phantom record should not yet have any children stored on the server, we set "loaded" to true when it is appended so that it does not attempt to load when expanded.

I can't imagine a case where you would need to load children for a phantom record. Are you creating a record client-side that is assumed to have children server-side? If so, you could either assign it an id when it is created, or set its "loaded" field back to false after appending it. I'm not sure either solution is really desirable. Could you provide more details as to exactly what you're trying to accomplish here?

30 Dec 2011, 12:18 PM
You decided that my record was phantom simply because I didnt set its ID when I created it. This is an interface change

I used to go

var rec = Ext.Create("my record class")
rec.set('id', <id>)

This worked fine in 4.0.7

Now I have to go

var rec = Ext.Create("my record class", {id: <id>});

Its OK , but it was surprising (and took a long time to debug)