PDA

View Full Version : Extra parameters in Ext.create...



drunkmoose
10 Jul 2014, 6:36 AM
Hello

I'm trying to pass extra parameters in a call to Ext.create.

This (http://www.sencha.com/forum/showthread.php?150238-How-do-you-send-parameters-into-a-Ext.create-(Error-in-documentation))shows how to do it but misses the part where you actually use the value within the config of the object.

I tried:



var contactWindow = Ext.create('widget.EditContactWin', { animateTarget: animTarget, formUrl: GlobalVars.contactPostApiUrl });


Then in the view:



Ext.define('Customer_Portal_UI.view.MainContent.editContactWin', {
alias: 'widget.EditContactWin',
extend: 'Ext.Window',
height: 525,
overflowY: 'auto',
width: 450,
bodyStyle: 'background-color:white;',
resizable: false,
modal: true,
items: [
{
xtype: 'form',
frame: false,
bodyStyle: 'background-color:white;border-width: 0px;',
url: this.formUrl,
id: 'EditContactForm',
trackResetOnLoad: true,
method: 'POST',
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
defaults: {minWidth: 100},
items: [
{ xtype: 'component', flex: 1 },
{ xtype: 'button', text: "OK", width: 100, id: 'contactFormSubmitButton' }
]
}],
items: [
{
xtype: 'fieldset',
columnWidth: 0.5,
style: 'border-width: 0px;background-color:white',
bodyStyle: 'background-color:white;',
defaults: {
anchor: '100%'
},
layout: 'anchor'
},
{
xtype: 'hidden',
name: 'sessionToken'
}
]
}
]
});



This doesn't work, either says formUrl is undefined or assigns null...

As I said, the first solution doesn't tell much and the documentation only mentions "args".... Then what? In the view I use arg.1, arg.2 ? $1, $2 ?

My attempt could probably work, but the scope seems wrong...

Thanks

skirtle
10 Jul 2014, 8:17 AM
In your example this refers to the global window object.

The standard way to do what you're trying to achieve is to override the initComponent method. Within that method this will refer to the instance.


Ext.define('Customer_Portal_UI.view.MainContent.editContactWin', {
...

initComponent: function() {
this.items = [
{
...
url: this.formUrl
},
...
];

this.callParent();
}
});

drunkmoose
11 Jul 2014, 6:32 AM
Of course, I saw that many times, don't know why I did not think of it myself. Thanks.