PDA

View Full Version : EXTJS with java



dtrprasad
26 May 2012, 8:37 AM
I am having java servlet that sends
response as
[
{"ambition":"To go to Singapore as a Java Developer","area":"JEE","devId":100,"name":"Madhavan","rank":"JD"},...............................
]

i am having a js file as


Ext.onReady(function() {
var myReader = new Ext.data.reader.Json(
{root: 'developers'},
[
{name: 'ambition'},
{name: 'area'},
{name: 'devId',type: 'int'},
{name: 'name'},
{name: 'rank'}
]);

var javaCompData = new Ext.data.Store({
proxy: new Ext.data.proxy.Ajax({
url:'/exjs/JsonEx1'
}),
reader: myReader
});


javaCompData.load();
alert('AAAAA'+javaCompData.data);
var grid = new Ext.grid.GridPanel({
store: javaCompData,
columns:[
{id:'devId',
header:'Developer-Id',width:85,
sortable:true,dataIndex:'devId'},
{header: 'Name',width:150,dataIndex:'name'},
{header: 'Area',width:80,dataIndex:'area'},
{header: 'Rank',width:80,dataIndex:'rank'},
{header: 'Ambition',width:300,dataIndex:'ambition'}
],
viewConfig:{forceFit:true},
width:695,
height:200,
enableColumnMove:true,
split:true,
region:'west',
title:'Developer Details'
});
grid.render('servlet-grid');


});


the html is


<html>
<head>
<link rel="stylesheet" type="text/css"
href="extjs/resources/css/ext-all.css" >
<script type="text/javascript" src="extjs/ext-all-debug.js">
</script>
<script type="text/javascript" src="extjsEx1.js">
</script>
<title>Showing Servlet Fetched Data</title>
</head>
<body>
<div id="servlet-grid"></div>
</body>
</html>


when ever it runs chrome browser only grid columns are seen and no data is found
no info in javascript console
[ component is contacted and data is being sent ]
i had given alert
it is showing [object Object]

can anybody help me

[email protected]

chramer
26 May 2012, 11:07 AM
delete this line

{root: 'developers'}
here is why (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader-cfg-root)

dtrprasad
26 May 2012, 6:21 PM
I did it but no use same is page no errors, no data

evant
26 May 2012, 7:27 PM
The fields don't go in the reader, they go in the model. I'd suggest looking at the grid examples again.

dtrprasad
27 May 2012, 1:49 AM
I did used a Model then it is coming ,

Thanks a lot for your advice