[Users] How to populate an ext. form by clicking on vector attributes in a map

Robert Buckley robertdbuckley at yahoo.com
Wed Mar 30 15:42:53 CEST 2011


Hi,

I have a map which creates a popup grid when a vector is clicked.

I would like the contents of the the selected features to appear in a form.

I can do this from a "grid" with the following code,


var popfieldset = function(){
                    gridPanel.getSelectionModel().each(function(rec){
                        var feature = rec.get("feature");
                        InfoPanel.getForm().loadRecord(rec);
                        
mapPanel.map.setCenter(feature.geometry.getBounds().getCenterLonLat(), 12);
                    })
                };


but I can´t figure out how to do it from the map.

This is the code for the fieldset

 var fieldset = {
                    id:"fieldset",
                    region: "center",
                    columnWidth: 0.5,
                    xtype: 'fieldset',
                    height: 250,
                    labelWidth: 90,
                    title: 'WEA Attribute',
                    defaults: {
                        width: 230
                    },
                    defaultType: 'textfield',
                    bodyStyle: Ext.isIE ? 'padding:0 0 5px 15px;' : 
'padding:10px 15px;',
                    items: [{
                        id: 'bez',
                        fieldLabel: 'WEA Kennung',
                        name: 'bez',
                        width: 50
                    }, {
                        id: 'standort',
                        fieldLabel: 'standort',
                        name: 'standort',
                        width: 250,
                        style: 'text-align:left;'
                    }, {
                        id: 'Betreiber',
                        fieldLabel: 'Betreiber',
                        name: 'betreiber',
                        width: 250,
                        style: 'text-align:left;'
                    }, {
                        id: 'typ',
                        fieldLabel: 'Anlagentyp',
                        name: 'typ',
                        width: 250,
                        style: 'text-align:left;'
                    }]
                };

..and this is the code for the popup


code from the popup?


layer.events.on({
                    featureselected: function(event){
                        gridPanel.getSelectionModel().each(function(rec){
                        var feature = rec.get("feature");
                        InfoPanel.getForm().loadRecord(rec);
                        
mapPanel.map.setCenter(feature.geometry.getBounds().getCenterLonLat(), 12);
                                })
                                                popup = new GeoExt.Popup({
                            title: "Feature Attributes",
                            feature: event.feature,
                            collapsible: true,
                            layout: "fit",
                            height: 330,
                            panIn: true,
                            width: 270,
                            unpinnable: true,
                            border: false,
                            listeners: {
                                close: function(){
                                    select.unselectAll();
                                }
                            },
                            items: [new Ext.grid.PropertyGrid({
                                autoHeight: true,
                                source: event.feature.attributes
                            })]
                        
                        });
                        popup.show();
                        popfieldset();
                    },
                    featureunselected: function(event){
                        popup.destroy();
                    }
                    
                });
                
                layer.events.on({
                    'featureselected': function(feature){
                        gridPanel.getSelectionModel().each(function(rec){
                            var feature = rec.get("feature");
                            InfoPanel.getForm().loadRecord(rec);
                            
                        })
                        
                    }
                });


can I can populate the fields in the form manually with this...

                        Ext.getCmp('Betreiber').setValue('Betreiber');
                        Ext.getCmp('standort').setValue('standort');
                        Ext.getCmp('typ').setValue('typ');

..but how do I populate the fields from the selectedfeature?

Thanks for any tips,

Robert




More information about the Users mailing list