PDA

View Full Version : Controller passing configs to views



romerve
2 May 2012, 2:30 PM
Hello,

I am trying to find a way to to pass config params to a view and instantiate it with them. My view is:


Ext.define('Que.view.Quesearch',{
extend: 'Ext.ux.form.SearchField',
alias: 'widget.quesearch',


config:{
emptyText: 'Enter Part#',
height: 20,
width: 600,
renderTo: 'site_search'
},


initComponent: function(){

Ext.apply(this, this.config);

this.callParent(arguments);
}

});


In my controller i have tried to do:

Ext.create('widget.quesearch', {emptyText: 'asdsad'});


But the initComponent seems to take overwrite any config sent.

Any ideas?

Thanks

vietits
2 May 2012, 3:27 PM
Try this:


Ext.define('Que.view.Quesearch',{
extend: 'Ext.ux.form.SearchField',
alias: 'widget.quesearch',


// config:{
emptyText: 'Enter Part#',
height: 20,
width: 600,
renderTo: 'site_search'
// },
initComponent: function(){
// Ext.apply(this, this.config);
this.callParent(arguments);
}
});

BTW: If there is nothing to do inside initComponent(), you should remove it out.

romerve
3 May 2012, 6:20 AM
Try this:


Ext.define('Que.view.Quesearch',{
extend: 'Ext.ux.form.SearchField',
alias: 'widget.quesearch',


// config:{
emptyText: 'Enter Part#',
height: 20,
width: 600,
renderTo: 'site_search'
// },
initComponent: function(){
// Ext.apply(this, this.config);
this.callParent(arguments);
}
});

BTW: If there is nothing to do inside initComponent(), you should remove it out.

Yeah, i know that it works as you suggested, i had previously done it like that, but i read somewhere in the docs that if you dont want the configs to be read only, you need to use the config{} param. Is this not the case?

Thanks