PDA

View Full Version : [4.0.2a] Loading two stores concurrently - bug?



slemmon
18 Aug 2011, 10:13 PM
I've got an event listener whose handler loads two stores like so:
Ext.data.StoreManger.get('Customers').load({params: myParamsObject})
Ext.data.StoreManger.get('Quotes').load({params: myParamsObject})

When doing this I get two loads. But, both use the proxy for whatever store I have listed first. I switch the order and Quotes would load twice and Customers not at all.

Outputting the StoreManager or each store by ID to the console makes it seem like all is in order.

Does this sound like a bug or am I possibly doing something wonky?

raz0r1
18 Aug 2011, 10:16 PM
I do this very often and in my case it works nicely.
I use (in your case)


Ext.getStore('Customers').load({scope: this, params: myParamsObject});
Ext.getStore('Quotes').load({scope: this, params: myParamsObject});


maybe it helps

slemmon
18 Aug 2011, 10:37 PM
I had high hopes there, but I'm afraid it's still loading just the one store twice.
* I like the getStore(), BTW - nice.
I used:


Ext.getStore('Customers').load({ scope: this, params: extents })
Ext.getStore('Quotes').load({ scope: this, params: extents })

I also tried the following since these are called from a controller method and 'this' is the controller:


var cStore = Ext.getStore('Customers')
var qStore = Ext.getStore('Quotes')
cStore.load({ scope: cStore, params: extents})
qStore.load({ scope: qStore, params: extents})

Still getting the first store twice.

I even tried:


Ext.getStore('Customers').load({ scope: this, params: extents })
Ext.defer(function(){
Ext.getStore('Quotes').load({ scope: this, params: extents })
}, 7000)

Wondered if deferring the second load until after the first would help - it did not, sadly.

raz0r1
18 Aug 2011, 11:01 PM
I think it belongs to your stores definition.
Can you post both?

slemmon
18 Aug 2011, 11:06 PM
Sure.

Customer Model

Ext.define('AMA.model.Customer', {
extend: 'Ext.data.Model'
, alias: 'model.amacustomermodel'


, proxy: {
type: 'ajax'
, url: 'servlet.aspx'
, extraParams: {
store: 'customer'
}
, reader: {
type: 'json'
, root: 'data'
, totalProperty: 'totalCount'
}
}
, fields: [
{ name: 'META_EFF_START_DATE' }
, { name: 'META_EFF_END_DATE' }
// ....
]
});


Customer Store

Ext.define('AMA.store.Customers', {
extend: 'Ext.data.Store'
, alias: 'store.amacustomerstore'


, model: 'AMA.model.Customer'


});


Quote Model

Ext.define('AMA.model.Quote', {
extend: 'Ext.data.Model'
, alias: 'model.amaquotemodel'


, proxy: {
type: 'ajax'
, url: 'servlet.aspx'
, extraParams: {
store: 'quote'
}
, reader: {
type: 'json'
, root: 'data'
, totalProperty: 'totalCount'
}
}
, fields: [
{ name: 'META_EFF_START_DATE' }
, { name: 'META_EFF_END_DATE' }
, { name: 'META_CUR_REC_IND' }
, { name: 'AMA_QUOTES_ID' }
// ....
]
});


Quote Store

Ext.define('AMA.store.Quotes', {
extend: 'Ext.data.Store'
, alias: 'store.amaquotestore'


, model: 'AMA.model.Quote'


});

raz0r1
18 Aug 2011, 11:16 PM
try to define the proxy within the store.
thats the only thing I do in another way
and if you dont use the aliases, remove them because in general you allocate them with .getStore() so an alias is not needed.

slemmon
18 Aug 2011, 11:38 PM
No dice. Was worth a shot. Cannot seem to get it to load both stores. Keeps loading one store twice.

raz0r1
18 Aug 2011, 11:49 PM
then i can not help you :(
try to debug with console.log(store); directly before you call store.load(); and compare them. find what is set wrong.
try also console.log(store1 == store2); and console.log(store1 === store2);
post then what you found out.

slemmon
22 Aug 2011, 6:04 AM
I never could get this to work. Calling out the store instances in the console showed them to be distinct. I think I'll move around this problem for now and see what I get in 4.1. Thx for looking into this with me, though!