PDA

View Full Version : Loader - dynamically use the params for the URL



kaolin1k
10 Dec 2011, 1:54 PM
Hello,

I am new in the filed ExtJs 4 , I tried the new feature loader like in the example from SENCHA docs


newExt.Component (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Component)({
tpl:'{firstName} - {lastName}',
loader:{
url:'myPage.php',
renderer:'data',
params:
{
userId:111111
}
}});

Where is my problem, how do you pass dynamically this userId ?
Here is my small sample, in this case userId is id.....


initComponent: function() {
this.items = this.createComponent( this.id);
this.callParent(arguments);
///// here I have the value of the ID with this.id (http://this.id/) but in the loader nooooooo :((
},



loader: {
url: Context.getContextRoot() + 'extjs4/test/testLoader.json',
params: {
//CHANGE DYNAMIC THE ID
id: 10402 //// <<<<<<<<<<<<<<here is the plase

//I cant use like this.id :((:((:((
},
autoLoad: true,
renderer: function (loader, response, active) {
var actions= Ext.decode(response. responseText);
loader.target.root. testStore.add( actions);
//loader.target.update();
loader.target.root.down('test_ TestLoaderToolbar').update();
return true;
}

},



Thank you in advace !

Best regards kaolin1k;

mitchellsimoens
11 Dec 2011, 6:39 AM
You want to use this.id? You need to set the params in the initComponent but not use autoLoad:


initComponent: function() {
this.loader.params : {
userId : this.id
};

this.loader.load();

this.callParent(arguments);
}

mitchellsimoens
11 Dec 2011, 6:39 AM
Aldo, please use the BBCode code tags (in the toolbar) and post into the appropriate forum. I have moved this thread for you.