[Users] Search using WFS Protocol

Graeme Gould graeme.gould at grandunionhousing.co.uk
Tue Jan 31 11:25:37 CET 2012


Please can I have some advice as to why the following code isn't working.  When you enter a search parameter using the formpanel and click search no results are displayed in the gridpanel, but a new blank layer called results is created.  I think it maybe something to do with connecting to Geoserver.

var protocol = new OpenLayers.Protocol.WFS({
                                    url: "http://192.168.10.44:8085/geoserver/wfs",
                                    version: "1.1.0",
                                    featureType: "aha_trees",
                                    featureNS: "http://www.grandunionhousing.co.uk/guhg_data",
                                    srsName: epsg27700,
                                    geometryName: "geometry"
});
var features = new Array();
");
var selects = new GeoExt.grid.FeatureSelectionModel();
var cols = [
            {name: 'tree_ref', type: 'string'},
            {name: 'x', type: 'string'},
            {name: 'y', type: 'integer'}
];
var reader = new GeoExt.data.FeatureReader({}, cols);
var store = new GeoExt.data.FeatureStore({
                                    id: "gridStore",
                                    reader: reader,
                                    fields: cols,
                                    autoLoad: false
});

var formPanel = new GeoExt.form.FormPanel ({
            title: "Postcode Search",
            height: 100,
            width: 350,
            bodyStyle: "padding: 5px;",
            region: "north",
            protocol: protocol,
            items: [{
                        xtype: "textfield",
                        name: "tree_ref__like",
                        allowBlank: false,
                        fieldLabel: "Tree Reference",
                        minLength: 1
            }],
            listeners: {
                        actioncomplete: function(form, action) {
                                    features = action.response.features;
                                    store.loadData(features);
                                    vm=app.mapPanel.map.getLayersByName("Results");
                                    if (vm.length===0) {
                                                vecLayer = new OpenLayers.Layer.Vector("Results");
                                                app.mapPanel.map.addLayer(vecLayer);
                                                store.bind(vecLayer);
                                                selects.bind(vecLayer);
                                    }
                        }
            },
            buttons: [{
                        text: "Search",
                        handler: function() {
                                    var mygrid = Ext.getCmp('gridPanel');
                                    mygrid.expand();
                                    formPanel.search();
                        },
                        scope: formPanel
    }],
            keys: [{
                        key: [Ext.EventObject.ENTER],
                        handler: function() {
                                    var mygrid = Ext.getCmp('gridPanel');
                                    mygrid.expand();
                                    formPanel.search();
                        }
            }]
});

var gridPanel = new Ext.grid.GridPanel({
            id: "gridPanel",
            title: "Results",
            region: "center",
            collapsible: true,
            collapsed: false,
            store: store,
            height: 500,
            stripeRows: true,
            autoExpandColumn: 'tree_ref',
            columns: [{
                        id: "tree_ref",
                        header: "Tree Reference",
                        width: 50,
                        sortable: true,
                        dataIndex: "tree_ref"
    }, {
                        id: "x",
                        header: "Lat",
                        width: 50,
                        dataIndex: "x"
            }, {
                        id: "y",
                        header: "Lon",
                        width: 50,
                        dataIndex: "y"
    }],
            sm: selects
});

searchPanel = new Ext.Panel({
            layout: "border",
            region: "east",
            collapsible: true,
            width: 250,
            items: [formPanel, gridPanel]
})

Any help would be most appreciated.

Graeme


---------------------------------------------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and intended solely for the use 
of the individual or entity to whom they are addressed. If you have received this email in 
error please let us know by email reply and delete it from your system. 

Please note that any views or opinions presented in this email are solely those of the 
author and do not necessarily represent those of Grand Union Housing Group. 

Finally, the recipient should check this email and any attachments for the presence of viruses. 
Grand Union Housing Group accepts no liability for any damage caused by any virus 
transmitted by this email. 

Grand Union Housing Group
Registered Office: 
Katherines House
Dunstable Street
Ampthill
Bedfordshire
MK45 2JP 
Registered under the Industrial and Provident Societies Act 1965 Registered No. 30388R 
Housing Corporation Registered No. L4518 

http://www.grandunionhousing.co.uk
--------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120131/3e62d02c/attachment-0001.htm 


More information about the Users mailing list