PDA

View Full Version : Struts2 Ext-js Datagrid data rendering problem



Kafir
8 Feb 2010, 1:52 PM
Hello all,
I am new to Ext-js and I am trying to make datagrid work with my struts application.

Following is my javascript.

Ext.onReady(function(){
var store = new Ext.data.JsonStore({
url: 'testJson',
fields: [
'id', 'firstName', 'lastName'
]
});

store.load();

var grid = new Ext.grid.GridPanel({
store : store,
columns : [
{header: 'id', width: 100, sortable: true, dataIndex: 'id'},
{header: 'firstName', width: 100, sortable: true, dataIndex: 'firstName'},
{header: 'lastName', width: 100, sortable: true, dataIndex: 'lastName'}
],
stripeRows: true,
height: 250,
width: 500,
title: 'DB grid'
});
grid.render('user');
});

Following is the code in my JSP page

<div id="user"></div>

and the following is the JSON response

{"success":true,"users":[{"firstName":"James","id":"id1","lastName":"Dean"},{"firstName":"Brad","id":"id2","lastName":"Pitt"},{"firstName":"George","id":"id3","lastName":"Clooney"}]}

It displays the grid with the header but it doesn't display any data...

Could anyone tell me what is wrong with it? is it 'dataIndex'?

Kafir
8 Feb 2010, 2:47 PM
Okay that was stupid on my part. I forgot to read "success" and root "users" duhh!