PDA

View Full Version : when store config variables are initialized.



Payoffice
27 Nov 2012, 6:20 AM
Hello,

I am new to ExtJs and I face the following problem.
I have two functions that initialize two stores initStore1() et initStore2() and a member variable this.id. This function are called in that order:

Ext.apply(this, {
id: -1;
})
initStore1();
initStore2();

The content of that function are the following:

function: initStore1() {
var store: nex Ext.data.Store({
...
listeners: {
load: {
scope: this,
fn: function(store, record) {
...
this.id = record.get('id');
}
}
}
})
}

function: initStore2() {
var store2: nex Ext.data.Store({
...
baseParams: {
...
where: "id" = this.id//here this.id is equal to -1 instead of the value present in store1
},
...
}
})
}

my problem is taht this.id is equal to -1 when initStore2 is called.
How can I initialize this.id so that it will be initialize before initStore2 is called?

Regards

Payoffice
27 Nov 2012, 7:57 AM
No answer?
I think my problem can be solved if I can load synchronously my stores.
Any idea?

Regards,

Payoffice

willigogs
27 Nov 2012, 8:17 AM
If I'm understanding the issue, why don't you call initStore2() in the load listener of initStore1() and pass the id?

e.g:


function: initStore1() {
var store: new Ext.data.Store({
listeners: {
load: {
scope: this,
fn: function (store, record) {
this.id = record.get('id');
initStore2(this.id)
}
}
}
});
}


function: initStore2(id) {
var store2: new Ext.data.Store({
baseParams: {
where: id
}
});
}

Payoffice
27 Nov 2012, 10:12 AM
hum, I will try it.

Regards,

Payoffice