PDA

View Full Version : How to set treepanel value before display



silan
22 Aug 2011, 8:03 AM
My tree store get data from server, so the data is not static.
The initial data has no node checked. I want to pass in some node IDs, so the nodes with these IDs are checked before or immediately after the tree get displayed.
I get the tree node I want to change with getNodeById, then used mynode.checked = true, but this doesn't really work (no error either). I thought maybe the node was not associated (as reference) with the tree so I need to write the changed node back to the tree. But I don't see any documented method doing that.

skirtle
22 Aug 2011, 9:35 PM
Behind the scenes the node is represented by a record in a store. All your current code does is set a property on a record. This won't cause an error but as nothing ever reads that property it won't have any effect.

Perhaps this instead?


tree.getStore().getNodeById(...).set('checked', true);

Worked for me.

silan
23 Aug 2011, 8:16 AM
Hi Skirtle,
Very appreciate your response!
Yes, your code resolves the problem. I was trying directly access the store.
Thanks!