数据表格分页查询显示
$(function(){
$("body").css({visibility:"visible"});
$('#grid').datagrid( {
iconCls : 'icon-forward',
fit : true,
border : true,
rownumbers : true,
striped : true,
pageList: [30,50,100],
pagination : true,
toolbar : toolbar,
url : "../../waybill_pageQuery.action",
idField : 'id',
columns : columns,
onDblClickRow : doDblClickRow,
onAfterEdit : function(rowIndex, rowData, changes){
$.post("../../waybill_save.action",rowData,function(data){
if(data.success){
$.messager.show({
title:'提示窗口',
msg:data.msg,
});
$("#grid").datagrid('reload');
}
});
console.info(rowData);
editIndex = undefined;
}
});
});
在 WayBillAction 添加 pageQuery 的方法
@Action(value = "waybill_pageQuery", results = { @Result(name = "success", type = "json") })
public String pageQuery() {
Pageable pageable = new PageRequest(page - 1, rows, new Sort(new Sort.Order(Sort.Direction.DESC, "id")));
Page<WayBill> pageData = wayBillService.findPageData(model, pageable);
pushPageDataToValueStack(pageData);
return SUCCESS;
}
编写业务层代码
@Override
public Page<WayBill> findPageData(WayBill model, Pageable pageable) {
return wayBillRepository.findAll(pageable);
}