I am trying to fetch the data from JSON and display it onto the grid. The store has all the JSON data, but I it is not visible in the Grid. The grid comes out completely blank.
This is the application, http://128.196.142.12/geo/test/test_new.html, select the Bioclim Data tool from the toolbar, on the top right and then click on the map.
Here is the entire code,
action = new GeoExt.Action({
text: "BioClim Data",
control: new OpenLayers.Control.Click({
//control.events.on({"click": function(evt) {
trigger: function(evt) {
var lonLat = evt.xy;
var proj = new OpenLayers.Projection("EPSG:4326");
var nlonLat = new OpenLayers.LonLat(panel.map.getLonLatFromViewPortPx(lonLat).lon, panel.map.getLonLatFromViewPortPx(lonLat).lat);
nlonLat.transform(panel.map.getProjectionObject(), panel.map.displayProjection);
if (popup) popup.close();
var request = Ext.Ajax.request({
url:"/cgi-bin/proxy.cgi?url=http://128.196.142.12:9000/info?lat="+ nlonLat.lat +"&lon="+ nlonLat.lon,
disableCaching: false,
success: function(response) {
var obj = Ext.decode(response.responseText);
var jsonData = Ext.util.JSON.decode(response.responseText);
//console.dir(obj);
store = new GeoExt.data.FeatureStore({
layer: features,
fields: jsonData,
autoLoad: true
});
addToPopup(lonLat, response.responseText);
var grid = new Ext.grid.GridPanel({
title: "BioClim Table",
store: store,
width: 600,
height: 250,
stripeRows: true,
columns: [{
header: "Annual Mean Temperature",
width: 200,
dataIndex: "mat"
}, {
header: "Mean Diurnal Range",
width: 200,
dataIndex: "mdr"
}, {
header: "Isothermality",
width: 100,
dataIndex: "iso"
}, {
header: "Temperature Seasonality",
width: 200,
dataIndex: "tsd"
}, {
header: "Max Temperature of Warmest Month",
width: 200,
dataIndex: "maxtwm"
}, {
header: "Min Temperature of Coldest Month",
width: 200,
dataIndex: "anntmin"
}, {
header: "Temperature Annual Range",
width: 200,
dataIndex: "tar"
}, {
header: "Mean Temperature of Wettest Quarter",
width: 200,
dataIndex: "meantwq"
}, {
header: "Mean Temperature of Driest Quarter",
width: 200,
dataIndex: "meantdq"
}, {
header: "Mean Temperature of Warmest Quarter",
width: 200,
dataIndex: "meantwaq"
}, {
header: "Mean Temperature of Coldest Quarter",
width: 200,
dataIndex: "meantcq"
}, {
header: "Annual Precipitation",
width: 150,
dataIndex: "annprec"
}, {
header: "Precipitation of Wettest Month",
width: 200,
dataIndex: "precwm"
}, {
header: "Precipitation of Driest Month",
width: 200,
dataIndex: "precdm"
}, {
header: "Precipitation Seasonality",
width: 200,
dataIndex: "precs"
}, {
header: "Precipitation of Wettest Quarter",
width: 200,
dataIndex: "precwq"
}, {
header: "Precipitation of Driest Quarter",
width: 200,
dataIndex: "precdq"
}, {
header: "Precipitation of Warmest Quarter",
width: 200,
dataIndex: "precwarmq"
}, {
header: "Precipitation of Coldest Quarter",
width: 200,
dataIndex: "preccq"
}],
//sm: new GeoExt.grid.FeatureSelectionModel()
listeners: {render:function(grid){
grid.getSelectionModel().selectFirstRow();
}}
});
/*var exportCSV = new Ext.ux.Exporter.Button({
component: grid,
text : 'Download CSV'
});
grid.getTopToolbar().add(exportCSV);*/
var win = new Ext.Window({
width: 600,
height: 300,
autoScroll: true,
title: "BioClim Data",
/*tbar: [{
text: 'Download CSV',
handler: new Ext.ux.Exporter.Button({
//alert('Downloads the CSV');
component: grid
})
}],*/
listners:{show:function() {
this.loadMask = new Ext.LoadMask(this.body, {
msg:'Loading. Please wait...'
});
}},
items: grid
});
win.show();
},
failure: function(response) {
console.log('server-side failure with status code ' + response.status);
addToPopup(lonLat, "Server side Failure");
}
//callback: myhandler
});
}}),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
tooltip: "Fetch BioClim Data",
// check item options
group: "newTool"
});
actions["bioclim"] = action;
toolbarItems.push(action);
