PDA

View Full Version : get "Window" and "Menu" items...



ahsec
21 May 2012, 12:29 AM
Hi everyone...

I created a window

however I wanted to open the window when clicking a button...

this is the window


Ext.define('MyApp.view.Login', { extend: 'Ext.window.Window',


draggable: false,
height: 250,
hidden: false,
id: 'login_win',
itemId: 'login_win',
width: 400,
resizable: false,
closable: false,
title: 'Login',......




and this is hot I tried to get it...

var a = Ext.WindowManager.get("login_win");

However a always gets "undefined"....
it seems that for some reason the window manager doesn't even hold any windows I create

Any ideas anyone?

friend
21 May 2012, 3:47 AM
Ext.define() (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext-method-define) simply defines a new Class. You have to create an instance of the target Class, where the instance will then be managed by Ext.WindowManager.



Ext.define('MyApp.view.Login', {
extend: 'Ext.window.Window',
draggable: false,
height: 250,
id: 'login_win',
width: 400,
resizable: false,
closable: false,
title: 'Login'
});

Ext.create('MyApp.view.Login').show();

console.log('windows title = ' + Ext.WindowManager.get('login_win').title);

ahsec
21 May 2012, 4:51 AM
You made my day!

But, is the only way to get the window is by :


var win = create('MyApp.view.a_SearchAlert');
win.dowhatever();

??

for some reason I can't get it through the WindowManager using



var win = Ext.WindowManager.get(the id string);

friend
21 May 2012, 5:33 AM
The WindowManager only tracks floating components which have already been created. Only after you create your Window component will it be available to the WindowManager class.

ahsec
22 May 2012, 4:37 AM
this is what I tried
this worked:


var wizard = Ext.create('MyApp.view.RulesWizard');
wizard.show();


this didn't

var wizard = Ext.create('MyApp.view.RulesWizard');
Ext.WindowManager.get('RulesWizard').show();

I can't use the first one because I do not want to create it more than once, and using a global var is complex because its not on the same file....

Any Idea?