Я новичок в jqgrid и пытался смоделировать приведенный выше код, но он не работает.На стороне сервера я создал класс
public class TaskBean {
String orderId;
String realty;
String building;
String priority;
String action;
String assignee; // add getter/setter methods
}
TaskBeanList.java
public class TaskBeanList {
private String page;
private String total;
private String records;
private List<TaskBean> rows;
}
Код контроллера Spring
@RequestMapping("/page4.htm")
public @ResponseBody TaskBeanList getJQGridData(HttpServletRequest request, HttpServletResponse response) {
System.out.println("xml data");
List<TaskBean> taskList = new ArrayList<TaskBean>();
taskList.add(new TaskBean("Task1", "K-CY-329", "144", "G-3", "1", "Pending", "XYZ"));
taskList.add(new TaskBean("Task2", "K-CY-356", "165", "A-10", "4", "Closed", "ABC"));
taskList.add(new TaskBean("Task3", "K-CY-343", "768", "B-12", "3", "Pending", "IJK"));
taskList.add(new TaskBean("Task4", "K-CY-786", "918", "F-9", "2", "Open", "PQR"));
TaskBeanList tsklst = new TaskBeanList("1", "5", "20", taskList);
return tsklst;
}
Клиентский JS-код JQGrid
jQuery(document).ready(function(){
jQuery("#list3").jqGrid({
autowidth: true,
datatype : "json",
url: "http://localhost:8080/SpringMVC/page4.htm",
mtype: 'get',
colNames : ["Title","Order ID","Realty","Building",
"Priority","Action","Assignee"],
colModel : [
{label: "Title", name: "title", index: "Title", jsonmap: "orderId"},
{label: "OrderID", name: "orderId", index: "OrderID", jsonmap: "orderId"},
{label: "Realty", name: "realty", index: "Realty", jsonmap: "realty" },
{label: "Building",name: "building",index: "Building",jsonmap: "building"},
{label: "Priority",name: "priority",index: "Priority",jsonmap: "priority"},
{label: "Action", name: "action", index: "Action", jsonmap: "action" },
{label: "Assignee",name: "assignee",index: "Assignee",jsonmap: "assignee"}
],
sortname : "Title",
sortorder : "desc",
shrinkToFit: true,
viewrecords: true,
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "id",
userdata: "userdata",
subgrid: {root:"rows",
repeatitems: true,
cell:"cell"
}
}
}); });
Может ли кто-нибудь помочь решить эту проблему?Когда я вижу пример кода jqgrid, выглядит просто, но я не вижу никакого вывода.Страница вывода пуста.Пожалуйста, помогите решить.
Спасибо