PDA

View Full Version : Issue with Ext component registered and with Using Namespace



SumathiVijay
23 Feb 2012, 12:48 AM
Hi,
I have two JS files.
1) the Main JS file where the Main FormPanel is rendered. This MainFormPanel has a Ext.Toolbar with Ext.menu.Menu items.
2) the second JS file (say CFG.js) has another FormPanel, and this is the one that is to be loaded upon a click on a particular Menu Item in MainFormPanel (stated above).

In doing the above task, I am trying to register the FormPanel in CFG.js as below:
Ext.reg('CFGPanel', CFG.cfgFormPanel); //CFG is the Namespace and cfgFormPanel is the FormPanel here
How should I use this registered component in the MainFormPanel in the Main.js ??? Please help..

Thanks in advance...

mitchellsimoens
23 Feb 2012, 9:06 AM
Ext JS 3 or 4?

SumathiVijay
23 Feb 2012, 8:23 PM
I am using Ext JS 3.4.0.

mitchellsimoens
24 Feb 2012, 5:28 AM
Moved it to the Ext JS 3 Help forum as is appropriate.

darthwes
24 Feb 2012, 7:55 AM
Prove it.

Show me your ns statement. Should be
Ext.ns("CFG");

Show me the line of code that defined the formpanel, should be like
CFG.cfgFormPanel = Ext.extend(...

SumathiVijay
27 Feb 2012, 9:15 PM
Find below my code snippet. . .

CFG.js

Ext.ns("CFG"); Ext.onReady(function(){
CFG.cfgPanel = Ext.extend(Ext.form.FormPanel{
id: 'cfgPanel',
standardSubmit: true,
. . . . . . . . . . .
. . . . . . . . . . .
Ext.reg('CFGPanel', CFG.cfgPanel);

MainForm.js
. . .
. . . . .
var NOFMenu = new Ext.menu.Menu({
id: 'NOFMenu', width: 250, height: 42,
items: [
{ text: 'CFG',
listeners:
{
click: function()
{
CFGPanel.show();
}
},
. . . . .
. . . . . .

I guess the issue is with the MainForm.js only... where I am trying to use the registered component. Please help..!!

darthwes
27 Feb 2012, 9:30 PM
CFGPanel.show();

should be


this.myCfgPanel = new CFG.cfgPanel();
this.myCfgPanel.show();

or equiv.

SumathiVijay
27 Feb 2012, 10:23 PM
this.myCfgPanel = new CFG.cfgPanel();
this.myCfgPanel.show();

I believe I cannot have the keyword "this" in this case.
When I use the above option, I get the error, ""CFG.cfgPanel()" is not a constructor" :((((

darthwes
28 Feb 2012, 6:35 AM
You don't need Ext.onReady to preceede your class definition. Just declare it.

You don't have to use 'this'. You can just say


var x = new CFG.Whatever({...});
x.show();

SumathiVijay
28 Feb 2012, 9:16 PM
In my CFG.js, I have removed the Ext.onReady(...) and just started off with the panel creation.
Hpwever, in MainForm.js, I did the below:

1) on Click listener of the menu item I have: click: function()
{
var x=new CFG.cfgPanel();
x.show();
}
Still even after this it says "CFG.cfgPanel is not a constructor" ... This is what I got even before posting this thread. I believe the requirement is clear... OR

Simply, how can we use the Component registered in one JS file in a particular namespace, to use used in another JS file. Let me know this please...

Help me please....!!!