View Full Version : ext grid only displaying the first letter of array items

26 Mar 2012, 8:07 AM
I am using OpenLayers with Ext to produce a grid of layers with a few of their attributes.

a typical layer object looks like this...

var layer_1 = new OpenLayers.Layer.WMS("Layer 1 Title",
"http://myServer/geoserver/wms", {
layers: 'zgb:layer1',
projection: "EPSG:4326",
format: 'image/png',
transparent: true,
singleTile: true
}, {
'buffer': 0,
'opacity': 0.9,
'isBaseLayer': false,
'visibility': false,
metadata:"this is my new metadata"

I would like to add these layers to a map and then display the layer name and the "metadata" json member in a grid. I have managed to get so far as to create a grid which has the correct amount of rows, but only the first letter of the "metadata" config member is being shown...e.g for the above example only a "t" would be shown in the grid. Can anyone tell me why this is?

the code to the grid is here

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

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


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]

Thanks for any help,


26 Mar 2012, 9:46 AM
Is the sizing correct? It looks just form the code that you have option to do better in sizing.

27 Mar 2012, 12:27 AM
do you mean the sizing of the columns...as in

columns: [
header: "metadata",
width: 400,
dataIndex: "metadata",
sortable: true