Skip to main content
improved formatting
Source Link
urcm
  • 22.6k
  • 4
  • 58
  • 109

var myData = []; var x=mapPanel.map.layers; for (var i=0; i<x.length; i++) { // alert(mapPanel.map.layers[i].metadata); myData.push(mapPanel.map.layers[i].metadata); }

var store = new Ext.data.ArrayStore({ fields: [ {name: 'metadata'} ] });

store.loadData(myData);

var myStore = new GeoExt.data.LayerStore({ map: map, layers: mapPanel.layers });

var grid = new Ext.grid.GridPanel({ title: "Available Map Layers", region: "center", height: 300, viewConfig: {forceFit: true}, store: store, columns: [ { header: "metadata", dataIndex: "metadata", sortable: true } ] });

var metadataWin = new Ext.Window({ title: "Map layers", layout: 'fit', width: '600', height: 'auto', border: false, closable: true, collapsible: true, x: 450, y: 100, resizable: true, closeAction: 'hide', plain: true, items: [grid] }); metadataWin.show();

var myData = [];
var x=mapPanel.map.layers;
for (var i=0; i<x.length; i++) {
  // alert(mapPanel.map.layers[i].metadata);
    myData.push(mapPanel.map.layers[i].metadata);
}

var store = new Ext.data.ArrayStore({
        fields: [
           {name: 'metadata'}
        ]
        });

store.loadData(myData);

var myStore = new GeoExt.data.LayerStore({
    map: map,
    layers: mapPanel.layers
}); 
 
var grid = new Ext.grid.GridPanel({
        title: "Available Map Layers",
        region: "center",
        height: 300,
        viewConfig: {forceFit: true},
        store: store,
        columns: [
            {
                header: "metadata",
                dataIndex: "metadata",
                sortable: true
            }
        ]
    });
    
var metadataWin = new Ext.Window({
                title: "Map layers",
                layout: 'fit',
                width: '600',
                height: 'auto',
                border: false,
                closable: true,
                collapsible: true,
                x: 450,
                y: 100,
                resizable: true,
                closeAction: 'hide',
                plain: true,
                items: [grid]
           });
    metadataWin.show();     

var myData = []; var x=mapPanel.map.layers; for (var i=0; i<x.length; i++) { // alert(mapPanel.map.layers[i].metadata); myData.push(mapPanel.map.layers[i].metadata); }

var store = new Ext.data.ArrayStore({ fields: [ {name: 'metadata'} ] });

store.loadData(myData);

var myStore = new GeoExt.data.LayerStore({ map: map, layers: mapPanel.layers });

var grid = new Ext.grid.GridPanel({ title: "Available Map Layers", region: "center", height: 300, viewConfig: {forceFit: true}, store: store, columns: [ { header: "metadata", dataIndex: "metadata", sortable: true } ] });

var metadataWin = new Ext.Window({ title: "Map layers", layout: 'fit', width: '600', height: 'auto', border: false, closable: true, collapsible: true, x: 450, y: 100, resizable: true, closeAction: 'hide', plain: true, items: [grid] }); metadataWin.show();

var myData = [];
var x=mapPanel.map.layers;
for (var i=0; i<x.length; i++) {
  // alert(mapPanel.map.layers[i].metadata);
    myData.push(mapPanel.map.layers[i].metadata);
}

var store = new Ext.data.ArrayStore({
        fields: [
           {name: 'metadata'}
        ]
        });

store.loadData(myData);

var myStore = new GeoExt.data.LayerStore({
    map: map,
    layers: mapPanel.layers
}); 
 
var grid = new Ext.grid.GridPanel({
        title: "Available Map Layers",
        region: "center",
        height: 300,
        viewConfig: {forceFit: true},
        store: store,
        columns: [
            {
                header: "metadata",
                dataIndex: "metadata",
                sortable: true
            }
        ]
    });
    
var metadataWin = new Ext.Window({
                title: "Map layers",
                layout: 'fit',
                width: '600',
                height: 'auto',
                border: false,
                closable: true,
                collapsible: true,
                x: 450,
                y: 100,
                resizable: true,
                closeAction: 'hide',
                plain: true,
                items: [grid]
           });
    metadataWin.show();     
Source Link
Robert Buckley
  • 10.3k
  • 14
  • 80
  • 160

How to create a metadata json member for an openlayers layers object and display in extjs grid?

I want to do the following: add

metadata: "this is the layer metadata" 

....to my openlayers layer config.

This should then be presented in an extjs grid. I can use

alert(layername.metadata);

to display the string inside the config member so I know it works.

To display this in the extjs grid I have used the following code

var myData = []; var x=mapPanel.map.layers; for (var i=0; i<x.length; i++) { // alert(mapPanel.map.layers[i].metadata); myData.push(mapPanel.map.layers[i].metadata); }

var store = new Ext.data.ArrayStore({ fields: [ {name: 'metadata'} ] });

store.loadData(myData);

var myStore = new GeoExt.data.LayerStore({ map: map, layers: mapPanel.layers });

var grid = new Ext.grid.GridPanel({ title: "Available Map Layers", region: "center", height: 300, viewConfig: {forceFit: true}, store: store, columns: [ { header: "metadata", dataIndex: "metadata", sortable: true } ] });

var metadataWin = new Ext.Window({ title: "Map layers", layout: 'fit', width: '600', height: 'auto', border: false, closable: true, collapsible: true, x: 450, y: 100, resizable: true, closeAction: 'hide', plain: true, items: [grid] }); metadataWin.show();

the grid show the correct amount of rows, but only the first letter is shown....this is probably a newbie javascript error.

Can anyone see where i´m going wrong?

yours,

Rob