Forum



14:39

09/12/2011

Hi All -
I'm new to jqGrid. Maybe someone can help me out ? I posted a full description of the problem at Stackoverflow. So rather than repeating problem all over again, I have posted the link here:
jqGrid not being populated with JSON data from Java Servlet:
http://stackoverflow.com/quest.....va-servlet
Any help appreciated.
Thanks in advance.
16:55

19/08/2011

I'Hi!
In jqGrid:
jQuery("#campTimetable").jqGrid({
url:'/admin/getTimetable',
datatype: 'json',
...
In JavaServlet:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
logger.info("TimetableServlet doGet");
HttpSession session = request.getSession(true);
try
{
timetableList = getListFromSomeWhere ...
JSONObject responcedata=new JSONObject();
net.sf.json.JSONArray cell=new net.sf.json.JSONArray();
net.sf.json.JSONArray cellarray=new net.sf.json.JSONArray();
net.sf.json.JSONObject cellobj=new net.sf.json.JSONObject();
responcedata.put("page", Long.parseLong("1"));
Iterator<Timetable> itr = timetableList.iterator();
while(itr.hasNext()){
Timetable t = itr.next();
cellobj.put("id", t.getId());
cell.add(t.field0().toString());
cell.add( StringUtil.StringToTime( t.field1()));
cell.add( StringUtil.StringToTime( t.field2()));
cellobj.put("cell", cell);
cell.clear();
cellarray.add(cellobj);
}
responcedata.put("rows", cellarray);
response.setContentType("applisation/json");
PrintWriter out = response.getWriter();
out.print(responcedata);
out.flush();
}
catch(Exception e)
{
logger.error("Error TimetableServlet goGet: " + e.toString());
}
}
It's work for me.
KiT
Most Users Ever Online: 715
Currently Online:
51 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66