PDA

View Full Version : [CLOSED] Store does not load on the first time when using a proxy in an inherited model



wolfganga
16 Aug 2015, 8:50 AM
Ext version tested:

Ext 6.0.0 GPL

Browser versions tested against:


Goggle Chrome

Description:

Store does not load on the first time when using a proxy in an inherited model. You need to load it 2 times.

Steps to reproduce the problem:

Fiddle below.
Click the load button the first time - an empty records gets loaded.
Click the load button a second time - the store loads as expected.
Watch the XHR response, its always the same.

The result that was expected:

The store should load the data on the first store.load().

The result that occurs instead:

You initially need to load the store 2 times.


See comments in the code for more details. When running the fiddle, watch the console output - specifically the success and count message and the xhr response.
s8k

evant
17 Aug 2015, 7:39 AM
I don't think this is a bug. The model constructor isn't run until the first load operation is completed (when it's spinning up the records), so one the first request, the root/other reader properties aren't set.

It's not really a great pattern to follow, that means every model that gets constructed would setup the writer every time.

wolfganga
17 Aug 2015, 10:24 AM
I see your point.

But i did not find any other way to achive the following:

- Allow loading models as well as stores from the same base configuration ( here reader/writer).
- Have one place to define the reader/writer config.

Before going for the constructor, i tried the declarative syntax via config like below.
(note the missing 'url' attribute, since this shall be defined by the derived model or store). But i did not work.


proxy: {
reader: {
type: 'json'
,rootProperty: 'data'
,totalProperty : 'totalCount'
,successProperty: 'success'
,messageProperty : 'errors'
}
,writer: {
type: 'json'
,successProperty: 'success'
,messageProperty : 'errors'
}
//,url: '' // no url or type here because its the base class
}




The other option would be to explicit replicate the same reader / writer config in each model or store.

So is there a better approach to create a sort of a pre-configured base model, or is this simply not possible?

Thanks in advance

Wolfgang

wolfganga
19 Aug 2015, 1:22 AM
Hello,

I understand that the first testcase provided (using the model constructor) was closed.

However the issue to use a base model class with a partial proxy config still exists when using the config way. (Basically that was the reason to use the constructor way).

Find attached the testcase based on configs. As soon a proxy config exists in the derived class, it seems to wipe out any proxy config defined in the base class.

I would expect that only those settings would be overridden, that are defined in the derived class.

So in this case, the proxy definition in the derived class should simply apply only the "url" definition to the existing proxy definition from the base class.

Thank you

Wolfgang

P.S. If needed i will create a seperate post for this since it is techically a different issue.

The fiddle defines two derived models, you can (un)comment the models in the store to compare them.

se2