日期:2014-05-20 浏览次数:20741 次
$("#showData").flexigrid({ url: 'flexi/flexi!getData.action', //链接 dataType:'json', colModel : [ {display: '编号', name : 'id', width : 50, sortable : true, align: 'center'}, {display: '姓名', name : 'username', width : 100, sortable : true, align: 'center'}, {display: '年龄', name : 'age', width : 50, sortable : true, align: 'center', hide: false}, {display: '性别', name : 'sex', width : 50, sortable : true, align: 'center', hide: false}, {display: '邮编', name : 'email', width : 150, sortable : true, align: 'center', hide: false}, ], buttons : [ {name: '增加', bclass: 'add'}, {name: '删除', bclass: 'delete'}, {name: '修改', bclass: 'edit'}, ], searchitems : [ {display: '姓名', name : 'username', isdefault: true}, {display: '年龄', name : 'age'} ], sortname: "id", sortorder: "asc", title: '用户管理', height: 200 , width:700, showTableToggleBtn : true, usepager:true, });
<package name="json" namespace="/flexi" extends="json-default"> <action name="flexi" class="flexi.action.MyFlexiGridAction"> <result type="json"/> </action> </package>
public class MyFlexiGridAction extends ActionSupport { private Integer page;//当前页 private Integer totle;//共几页 private Integer rp;//每页显示条目 private List<People> rows; public String getData() { System.out.print("获取数据..."); rows=new ArrayList<People>(); for(int i=0;i<27;i++){ People p=new People(); p.setId("No."+i); p.setUsername("黄"+i); p.setAge("i"); p.setSex("男"); p.setEmail("hcw"+i+"@126.com"); rows.add(p); } int totlePage=rows.size()/this.getRp(); if(rows.size()%this.getRp()>0) totlePage +=1; this.setTotle(totlePage); System.out.print("共"+rows.size()+"条\n"); return null; } @JSON(name="page") public Integer getPage() { return page; } public void setPage(Integer page) { this.page = page; } @JSON(name="totle") public Integer getTotle() { return totle; } public void setTotle(Integer totle) { this.totle = totle; } @JSON(name="rp") public Integer getRp() { return rp; } public void setRp(Integer rp) { this.rp = rp; } @JSON(name="pList") public List<People> getRows() { return rows; } public void setRows(List<People> rows) { this.rows = rows; } }