jquery配合struts2.0分页

十一郎的IT 2010-03-30

Java代码






@Controller
public class InfoIssueAction extends PBaseAction {
 public InfoIssueAction(){};
 @Autowired
 InfoIssueService infoIssueService;

 List rows=new ArrayList();
 protected int rp;
 protected int page=1;
 protected int total;
 
 @SuppressWarnings("unchecked") 
 public String showInfoIssue(){
  int startIndex = (page - 1) * rp;     //计算查询开始数据下标        
  total=infoIssueService.getAllInfoIssue().size();
  List list=infoIssueService.getInfoIssue(startIndex, rp);
  for (Iterator iterator = list.iterator(); iterator.hasNext();) {
   InfoIssue infoissue = (InfoIssue) iterator.next();
     Map cellMap = new HashMap();  
     cellMap.put("issueid", infoissue.getIssueid());
     cellMap.put("cell", new Object[] {infoissue.getIssueid(),infoissue.getCaption(),
       infoissue.getAttribute(),infoissue.getMaketop(),infoissue.getIssued()});
     rows.add(cellMap);
   
  }
  return "listSuccess";
 }


 @JSON(name="rows")
 public List getRows() {
  return rows;
 }

 public void setRows(List rows) {
  this.rows = rows;
 }

 public int getRp() {
  return rp;
 }

 public void setRp(int rp) {
  this.rp = rp;
 }

 public int getPage() {
  return page;
 }


 public void setPage(int page) {
  this.page = page;
 }


 public int getTotal() {
  return total;
 }

 public void setTotal(int total) {
  this.total = total;
 }

}

需要导入文件,:

Java代码 

<script type="text/javascript" src="page/js/jquery.js"></script>
<script type="text/javascript" src="page/grid/flexigrid.js"></script>

Java代码

$("#flex1").flexigrid
   (
   {
   url: 'infoIssue/InfoIssue!show.action',
   dataType: 'json',
   colModel : [
    {display: '编号', name : 'issueid', width : 60, sortable : true, align: 'center'},
    {display: '标题', name : 'caption', width : 120, sortable : true, align: 'left'},
    {display: '是否置顶', name : 'maketop', width : 120, sortable : true, align: 'left'},
    {display: '是否发布', name : 'issued', width : 120, sortable : true, align: 'left'}
    ],
   buttons : [
    {name: '增加', bclass: 'add', onpress : test},
    {name: '删除', bclass: 'delete', onpress : test},
    {separator: true}
    ],
   searchitems : [
    {display: '标题', name : 'caption', isdefault: true}
    ],
   sortname: "issueid",
   sortorder: "asc",
   usepager: true,
   title: '新闻发布 ',
   useRp: true,
   rp: 1,
   showTableToggleBtn: true,
   width: 600,
   height: 300
   }
   );
   function test(com,grid)
   {
    if (com=='删除')
     {
         confirm('是否删除这 ' + $('.trSelected',grid).length + ' 条记录吗?')
     }
    else if (com=='增加')
     {
      alert('增加一条!');
     }   
   }

相关推荐

87281248 / 0评论 2013-03-27
82244951 / 0评论 2013-01-22