1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| @RequestMapping("/data") public JSONResult getData(String parameterValue, String dataSourceInfo, Integer startPage, Integer pageSize){ JSONArray columns = new JSONArray(); columns.add(createColumn("title","姓名","dataIndex", "grid_name")); columns.add(createColumn("title","年龄","dataIndex", "grid_age")); columns.add(createColumn("title","生日","dataIndex", "grid_birthday")); JSONArray data = new JSONArray(); data.add(createColumn("grid_name", "张三", "grid_age","12", "grid_birthday","2000-10-01","grid_id","11")); data.add(createColumn("grid_name", "李四", "grid_age","12", "grid_birthday","2000-10-01", "grid_id", "12")); data.add(createColumn("grid_name", "王五", "grid_age","12", "grid_birthday","2000-10-01", "grid_id", "13")); data.add(createColumn("grid_name", "赵六", "grid_age","12", "grid_birthday","2000-10-01", "grid_id", "15"));
JSONObject resdata = new JSONObject(); resdata.put("data", data); resdata.put("columns", columns); JSONObject res = new JSONObject(); res.put("data", resdata); res.put("totalCount", 10); res.put("pageNo", 1);
return new JSONResult().setResult(res); }
private JSONObject createColumn(String ... key) { JSONObject object = new JSONObject(); for (int i = 0; i < key.length; i+=2) { object.put(key[i], key[i+1]); } return object; }
|