Html
<div region="center" border="false" style="padding:0px 3px 0px 3px;margin:0px;">
<table id="test"></table>
</div>
初置化gird
$(function(){
loadgrid();
//loadcombobox(null);
});
function loadgrid(){
$('#test').datagrid({
title:'任免信息列表',
fit:true,
nowrap: false,
striped:false,
//url:'rm.json',
url:'http://127.0.0.1:8080/web/AppAndRemoveServer.server',
queryParams:{},
sortName: 'appandremove_id',
sortOrder: 'asc',
remoteSort: false,
idField:'appandremove_id',
frozenColumns:[[
{field:'ck',checkbox:true}
]],
columns:[[{field:'appandremove_id',title:'任免批次编号',200,sortable:true},
{field:'batch_name',title:'任免批次名称',240,sortable:true},
{field:'batch_no',title:'任免批次编号',100,sortable:true},
{field:'recorder_date',title:'登记时间',120,sortable:true},
{field:'recorder_id',title:'登记人',100,sortable:true},
{field:'state',title:'状态',100,sortable:true},
{field:'memo',title:'备注',300}
]],
pagination:true,
pageNumber:1,
pageSize:5,
pageList:[5,10],
//singleSelect:true,
rownumbers:true
});
}
服务端接收rows、page、order、sort参数
参数名称是easyui起的,值也是自动绑定
可以在服务端通过request.getParameterNames();查看有什么参数
接收参数值
if(null!=request.getParameter("rows")) { pageRows=Integer.parseInt(request.getParameter("rows").toString());
}
if(null!=request.getParameter("page")) {
page=Integer.parseInt(request.getParameter("page").toString());
}
if(null!=request.getParameter("order")) {
order=request.getParameter("order").toString();
}
if(null!=request.getParameter("sort")) {
order=request.getParameter("sort").toString();
}
然后拼装sql语句实现分页。
增加查询参数,重新加载表格
function reloadgrid (stateVal) {
//查询参数直接添加在url中
/* var url =$('#test').datagrid('options').url;
url = "http://127.0.0.1:8080/web/AppAndRemoveServer.server?state=" +stateVal;
//重新赋值url 属性
$('#test').datagrid('options').url=url;
$("#test").datagrid('reload');
*/
//查询参数直接添加在queryParams中
var queryParams = $('#test').datagrid('options').queryParams;
queryParams.state = stateVal;
$('#test').datagrid('options').queryParams=queryParams;
$("#test").datagrid('reload');
}