geoext2 icon indicating copy to clipboard operation
geoext2 copied to clipboard

FeatureStore with Proxy not working correctly with ExtJS 5

Open chrismayer opened this issue 9 years ago • 6 comments

I have discovered issues which prevent a FeaturStore loading its data via Proxy correctly when using ExtJS 5, like this:

Ext.create('GeoExt.data.FeatureStore', {
    layer: vecLayer,
    fields: [
        {name: 'name', type: 'string'}
    ],
    autoLoad: true,
    proxy: Ext.create('GeoExt.data.proxy.Protocol', {
        reader: Ext.create('GeoExt.data.reader.Feature', {root: 'features'}),
        protocol: new OpenLayers.Protocol.HTTP({
            url: "../data/busstops.geojson",
            format: new OpenLayers.Format.GeoJSON({})
        })
    })
});

This can be tested with the example here, which is by the way not listed on the GeoExt 2 webpage.

I found 2 reasons for this:

1.) In https://github.com/geoext/geoext2/blob/master/src/GeoExt/data/proxy/Protocol.js#L196 we call operation.setSuccessful(); which in ExtJS 5 also calls operation.setCompleted(); and we also call the later explicitly the line before. This leeds to a double call of the operation callbacks, what ends in an empty FeatureStore. In ExtJS 4 operation.setSuccessful() did not call operation.setCompleted() so this issue did not appear.

2.) Once the data is loaded correctly one will discover that the attributes of the loaded feature(s) are not mapped correctly to the record, so the UIs (e.g. columns a grid) will remain empty. Here it seems we have to apply the attributes explicitly in case of using ExtJS 5.

chrismayer avatar Feb 12 '16 11:02 chrismayer

@chrismayer, did you make this work in your application and would you be able to provide a PR?

bentrm avatar Feb 26 '16 07:02 bentrm

Hi @bentrm,

I recently started to fix this. 1.) isn't really a problem but 2.) is caused deep in the ExtJS 'proxy-/reader-world'. I already had a intensive look into that and could figure out that the error is related to the extractData-method of Ext-data-reader-Reader. In this method the fieldExtractorInfo remains empty which causes the wrong data mapping in our records. I am sure if we find the cause for the empty fieldExtractorInfo we can fix the problem. Would be cool if someone else could have a look on that. I will also proceed if I have free timeslots.

Shall I open a PR with the fix for 1.) which can be used a base for further commits?

chrismayer avatar Feb 26 '16 11:02 chrismayer

It's a good start I guess. The whole Ext-proxy/reader stuff :copyright: is a bit hard to reason about..

bentrm avatar Feb 26 '16 11:02 bentrm

Is this in any way related to #173 and #162?

bentrm avatar Feb 26 '16 12:02 bentrm

I guess. At least #173 seems to be related somehow. For #162 I am not sure.

chrismayer avatar Feb 29 '16 06:02 chrismayer

I just opened a PR (#384) which fixes 1.) and can be used as base for further development.

chrismayer avatar Mar 01 '16 06:03 chrismayer