-
Store in a function
Hi,
I am a new user in ExtJS4 and I have a problem that i can't resolve..
I wanna put in a function this code :
Code:
var storeLD01_Objet = Ext.create('Ext.data.Store', {
fields :['id', 'libelle'],
labelWidth :150,
proxy: {
type: 'ajax',
url: '/value/TypeAmenrecherche/search',
reader: {
type: 'json',
root: 'elt'
}
},
listeners: {
'load': function(store, operation, options){
this.insert(0, {id:'--', libelle:'--'});
}
},
autoLoad: true
});
My objective is to have a function like :
function loadstore(link){
...
url: '/gtrte/link/search',
...
} because I want have a dynamic store who change with my value "link"
-
Code:
loadstore: function (link) {
this.getProxy ().url = 'foo' + link + 'bar';
this.load ();
}
-
Thank's.. It'is work now but when i used i can't do a selection in my combobox and i don't know why ..
Code:
var LD00_Nature = Ext.create('Ext.form.ComboBox', {
id :'nature',
fieldLabel :'Nature',
labelWidth :80,
store: storeLD00_Nature,
queryMode :'remote',
displayField :'libelle',
valueField :'libelle',
emptyText :'--',
editable :false,
listeners : {
select : function(liste, index){
if(liste.value=='Amenagement'){
storeLD01_Objet.getProxy ().url = '/gedeo/TypeAmenagement/recherche/',
storeLD01_Objet.load ();
}
if(liste.value=='Milieu'){
storeLD01_Objet.getProxy ().url = '/gedeo/TypeMilieu/recherche/',
storeLD01_Objet.load ();
}
}
},
border: 1
});
var storeLD01_Objet = Ext.create('Ext.data.Store', {
fields :['id', 'libelle'],
labelWidth :150,
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'elt'
}
},
listeners: {
'load': function(store, operation, options){
this.insert(0, {id:'--', libelle:'--'});
}
},
autoLoad: true
});
Can you tell me the problem please?
Thank you very much
-
Oups its Oki now...
I have forgot to add
url = '' in my Store..
Thank u for ur help
-
Is storeLD01_Objet a global variable? You are not providing any scope to the object.
-
Yes it is a global variable