PDA

View Full Version : JSON data doens't shot up in my Grid



Dtalpas
28 Jun 2011, 10:29 AM
Hello,

I have a JSP that uses java classes to derive some information about certain files in directories. The JSP returns a JSON-formatted string and shows up as expected on the server (Tomcat) and through firebug.

However, my Grid doesn't not render any of the data and I am completely stumped on why...

Below is my code.

Thank you in advance for any help offered!!



JavaScript

Ext.onReady(function(){


var ds = new Ext.data.JsonStore({
url: 'versioning.jsp',
root: 'Versions',
loadMask: true,
sortInfo: { field: 'type', direction:"ASC" },
autoLoad: false,
fields: [
'type',
'version',
'revision',
'date',
'name'
]

});

var versionGrid = new Ext.grid.GridPanel({
store: ds,
data: ds.data,
columns: [
{id:'Versions', header: "Type", width: 100, sortable: true, dataIndex:'type'},
{header: "Name", width: 200, sortable: true, dataIndex: 'name'},
{header: "Version", width: 200, sortable: true, dataIndex: 'version'},
{header: "Revision", width: 200, sortable: true, dataIndex: 'revision'},
{header: "Built At", width: 200, sortable: true, dataIndex: 'date'}
],

frame: true,
width: 900,
height: 450,
collapsible: true,
animCollapse: false,
title: 'Version View',
iconCls: 'icon-grid',
renderTo: document.body
});

ds.load();

});



JSON Data (Copied and pasted out of Firebug from under the response tag)

{"Versions": [{"type":"Widget","version":"v1.3.0 ","revision":"rev1.02","date":"05/12/2011, 5:50pm","name":"doclist"},{"type":"Widget","version":"v1.3.0 ","revision":"rev1.02","date":"05/12/2011, 5:50pm","name":"documentsearch"},{"type":"Widget","version":"v1.2 ","revision":"rev1.01","date":"04/15/2011, 3:50pm","name":"docviewer"},{"type":"Widget","version":"v1.3.0 ","revision":"rev1.02","date":"05/12/2011, 5:50pm","name":"entitylist"},{"type":"Widget","version":"v1.3.0 ","revision":"rev1.02","date":"05/12/2011, 5:50pm","name":"simplesearch"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/24/2011 ","name":"category-filter"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/10/2011 ","name":"chart"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/02/2011 ","name":"data-grid"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.02 ","date":"6/06/2011 ","name":"encoding-control"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/02/2011 ","name":"faceting-filter"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/16/2011","name":"map"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"entityTree"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"findSimilarDocuments"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"findSimilarEntities"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"ngram"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"similarDocumentReasons"},{"type":"Widget","version":"v1.3.0 ","revision":"revNONE","date":"5/10/2011 ","name":"similarEntityReasons"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.02 ","date":"6/06/2011","name":"record-clipboard"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/24/2011 ","name":"record-viewer"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/24/2011 ","name":"tag-cloud"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/16/2011","name":"temporal-control"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.02 ","date":"6/06/2011 ","name":"timeline"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/02/2011 ","name":"timewheel"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/10/2011 ","version":"value-list",{"type":"Widget","version":"v1.3.0 ","revision":"rev0.03 ","date":"5/20/2011 ","name":"working-set"},{"type":"Widget","version":"v1.3.0 ","revision":"rev0.01 ","date":"5/10/2011 ","name":"workspace"}]}

jjmiller1980
28 Jun 2011, 10:40 AM
Maybe with the way you're set up you don't need one, but I noticed you don't have a dataReader set up. If I had to guess I would say that's your problem.

Dtalpas
28 Jun 2011, 11:34 AM
Thanks, it was actually an improperly formatted JSON string that I was sending back, if it wasn't for your post I wouldn't have even looked at it!

Much appreciated!