geoext / geoext2

GeoExt 2 — JavaScript Toolkit for Rich Web Mapping Applications
http://geoext.github.io/geoext2/
Other
142 stars 106 forks source link

FeatureStore with Proxy not working correctly with ExtJS 5 #378

Open chrismayer opened 8 years ago

chrismayer commented 8 years ago

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.

bentrm commented 8 years ago

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

chrismayer commented 8 years ago

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?

bentrm commented 8 years ago

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

bentrm commented 8 years ago

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

chrismayer commented 8 years ago

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

chrismayer commented 8 years ago

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