Beispiel #1
0
  /** 复杂的Grid */
  @RequestMapping(
      value = "/complexGridData.do",
      method = {RequestMethod.GET})
  @ResponseBody
  public GridData<Staff> gridComplex(
      @RequestParam(P_START) int start, @RequestParam(P_LIMIT) int limit) {
    GridData<Staff> gridData = new GridData<Staff>();
    gridData.setTotal(staffService.getTotal());
    gridData.setRows(staffService.query(start, limit));

    return gridData;
  }
Beispiel #2
0
  /** 排序的Grid */
  @RequestMapping(
      value = "/sortgriddata.data",
      method = {RequestMethod.GET})
  @ResponseBody
  public GridData<Ip> gridSort(
      @RequestParam(P_START) int start,
      @RequestParam(P_LIMIT) int limit,
      HttpServletRequest request) {
    GridData<Ip> gridData = new GridData<Ip>();
    int end =
        (start + limit) > ipService.ipInfos().size() ? ipService.ipInfos().size() : (start + limit);
    String sortBy =
        CoreUtil.isNull(request.getParameter("sortBy")) ? null : request.getParameter("sortBy");
    String sortDir =
        CoreUtil.isNull(request.getParameter("sortDir")) ? null : request.getParameter("sortDir");

    if (CoreUtil.isNull(sortBy)) {
      gridData.setRows(ipService.ipInfos().subList(start, end));
    } else {
      final int sort = ASC.equals(sortDir) ? 1 : -1;
      Comparator<Ip> comparator = null;
      List<Ip> tempList = ipService.ipInfos();
      if ("city".equals(sortBy)) {
        comparator =
            new Comparator<Ip>() {
              @Override
              public int compare(Ip o1, Ip o2) {
                // TODO Auto-generated method stub
                return sort * o1.getCity().compareTo(o2.getCity());
              }
            };
      }
      Collections.sort(tempList, comparator);
      gridData.setRows(tempList.subList(start, end));
    }
    gridData.setTotal(ipService.ipInfos().size());

    return gridData;
  }
Beispiel #3
0
  /** 普通的Grid */
  @RequestMapping(
      value = "/demos/grid/griddata.do",
      method = {RequestMethod.GET})
  @ResponseBody
  public GridData<Ip> grid(@RequestParam(P_START) int start, @RequestParam(P_LIMIT) int limit) {
    GridData<Ip> gridData = new GridData<Ip>();
    gridData.setTotal(ipService.ipInfos().size());
    int end =
        (start + limit) > ipService.ipInfos().size() ? ipService.ipInfos().size() : (start + limit);
    gridData.setRows(ipService.ipInfos().subList(start, end));

    return gridData;
  }