PDA

View Full Version : want to show the data from the servlet to grid



abhijit.chanda
4 Jan 2013, 12:09 AM
JSONArray json=new JSONArray();
JSONObject obj=new JSONObject();

obj.put("username",UserVO.getUsername());
obj.put("password",UserVO.getPassword());

json.add(obj);

JSONobj.put("employee", json);
...................................................................
var store=new Ext.data.JsonStore({ //this is my grid.js where i want to show the data

url:'LoginServlet',
fields:[

'username','password'
]


});


store.load();


var grid=new Ext.grid.GridPanel({

store:store,
columns:[

{header:'username',width:100,dataIndex:'username'},
{header:'password',width:100,dataIndex:'password'}



],
height:250,
width:500

});//plz help

friend
4 Jan 2013, 7:49 AM
You need to ensure that your Servlet is setting the content type as "application/json".



response.setContentType("application/json");


You also need to ensure that your JSON conforms to the structure expected by the Ext.data.JsonStore (http://swatdevl/extjs-4.1.1/docs/index.html#!/api/Ext.data.JsonStore).