PDA

View Full Version : get a Component of a other view



KV Saarland
23 Feb 2015, 10:51 PM
Hi,

I have a Ext.tree.Panel and I like to show a "context" Menu onTreePanelItemContextMenu as well as onTreepanelContainerContextMenu. After choose a Menu entry I have to get the selectionModel to check if a node/leaf is selected.

For now the ContextMenu has a own View so it has a own Controller etc.

51811

now if the menu item is clicked ...
51812

how can I get the selection Model of the MainView.TreePanel ... Is there a way? Or did I have to define the events in my Main Controller? which way is the "right" way or let's say "best practice"

KV Saarland
23 Feb 2015, 11:11 PM
seems that


var treePanel = Ext.widget('mainview').getReferences().treePanel;

do the trick

evant
23 Feb 2015, 11:59 PM
Ext.widget() creates a new component instance, so you don't want to do that. I think that you should handle all of this within the tree panel controller.

KV Saarland
24 Feb 2015, 12:31 AM
Oh ok, thats why my selection is empty !?:((

But how can I handle the ContentMenu Events (item click) in the tree panel controller?? for example I choose "rename" from the context menu -> load the selected record to a form.

KV Saarland
24 Feb 2015, 2:24 AM
I could create a global reference to my mainView and access that via Project.app.getController('Main') ... but maybe there is a better way to share data and call function from one view controller to another?

KV Saarland
25 Feb 2015, 3:16 AM
http://stackoverflow.com/questions/24237744/extjs5-call-controller-2s-method-from-controller-1#answer-24238199