PDA

View Full Version : TreePanels selectionModel's node is not set when node is clicked



forumuser1080
9 Mar 2011, 8:09 AM
I have a TreePanel in the west and a FormPanel in the east. When a user clicks on a node I want to populate the FormPanel.

I create a record to pass to my form and I call loadRecord(record) on my form.

My problem happens because my form has a couple of checkboxes which will get data from the TreePanels selected node if checked. I.E. is the user clicks 'useInfoFromNode' checkbox the handler for the checkbox gets the selected node's info to populate some of the form fields within the form.

When I programatically check the box (because it gets checked based on the boolean value that is set when I create the record to call loadRecord(record) the call to getSelectionModel().getSelectedNode() is null.



listeners {
'click' : function(node event)
var record = // create my record
Ext.getCmp('my-form).getForm().loadRecord(record);
}


then I have a checkbox handler in my form


xtype: 'checkbox',
handler: function() {
var node = Ext.getCmp('my-tree').getSelectionModel().getSelectedNode();
// node is null because the node has not actually been selected yet
}


I was hoping for an afterclick event on the TreePanel but no such luck. Its either that or tell my checkbox to only invoke my handler if a user actually clicks the box and not when it is set by the Forms call to setValue().

Any ideas??

forumuser1080
9 Mar 2011, 5:22 PM
Is this a bug? Should the selectionModel be updated with the selected node when the click event fires?

Is there another event I can listen to such the the selectionModel has been updated, ie afterclick?