0
我有几个jqgrids运行,并且都运行良好。但是,当我进行搜索时,我只显示每页10个搜索结果。每当有超过十个结果时,点击第二页对网格没有影响。这里是我的控制器动作之一,尤其要注意的,如果satatement其中搜索是真的....Jqgrid搜索结果与Spring 3.0分页
编辑
我想我可能已经找到了线索,以什么可能导致我的问题。你看到我在主网格下有几个子网格。在我的Java代码术语具有对象-A具有对象-B 的列表,从而甲具有乙的子网格。我构建json字符串以馈入网格的方式是遍历B列表中A中包含的列表。我没有写任何类型的查询来说明顺序,并限制结果等。
所以我想真正的问题应该是如何建立一个集合上的查找器,以便内容可以安排和命令为我希望?
下面是我要求的一个实体,我的实体描述为B以上。要特别注意的地方,我说person.getContacts()
@RequestMapping(value = "contactjsondata/{pId}", method = RequestMethod.GET)
public @ResponseBody String contactjsondata(@PathVariable("pId") Long personId, Model uiModel, HttpServletRequest httpServletRequest) {
Person person = Person.findPerson(personId);
String column = "id";
if(httpServletRequest.getParameter("sidx") != null){
column = httpServletRequest.getParameter("sidx");
}
String orderType = "DESC";
if(httpServletRequest.getParameter("sord") != null){
orderType = httpServletRequest.getParameter("sord").toUpperCase();
}
int page = 1;
if(Integer.parseInt(httpServletRequest.getParameter("page")) >= 1){
page = Integer.parseInt(httpServletRequest.getParameter("page"));
}
int limitAmount = 10;
int limitStart = limitAmount*page - limitAmount;
List<Contact> contacts = new ArrayList<Contact>(person.getContacts());
double tally = Math.ceil(contacts.size()/10.0d);
int totalPages = (int)tally;
int records = contacts.size();
StringBuilder sb = new StringBuilder();
sb.append("{\"page\":\"").append(page).append("\", \"records\":\"").append(records).append("\", \"total\":\"").append(totalPages).append("\", \"rows\":[");
boolean first = true;
for (Contact c: contacts) {
sb.append(first ? "" : ",");
if (first) {
first = false;
}
sb.append(String.format("{\"id\":\"%s\", \"cell\":[\"%s\", \"%s\", \"%s\"]}",c.getId(), c.getId(), c.getContactType().getName() ,c.getContactValue()));
}
sb.append("]}");
return sb.toString();
}
您可以发布您的jsp/UI页面代码吗? –