EasyUI的datagrid分页

EasyUI的datagrid分页

EasyUI的datagrid分页

前台代码:

<script type="text/javascript">
$(function () {
//查询
search();
}); //查询
function search() {
var startDate = $("input[name='startDate']").val();
var endDate = $("input[name='endDate']").val(); //加载datagrid
$('#listdata').datagrid({
url: "@Url.Content("~/Backstage/MachineMng/CashMng/TouBiZhaoLingSearch")",
queryParams: { 'startDate': startDate, 'endDate': endDate },
columns: [[
{ field: 'addTime', title: '日期', width: 100 },
{
field: 'orderId', title: '摘要', width: 100, formatter: function (value, rowData, rowIndex) {
return "订单号:" + rowData["orderId"];
}
},
{ field: 'userName', title: '操作人', width: 100 },
{ field: 'opera', title: '操作', width: 100 }
]],
rownumbers: true,
pagination: true, //分页控件
pageList: [10, 20, 50],
pageNumber: 1,
singleSelect: true,
loadMsg: "数据加载中……",
fitColumns: true
}); //设置分页控件
var p = $('#listdata').datagrid('getPager');
$(p).pagination({
beforePageText: '第', //页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录'
});
}
</script>

后台:

public ActionResult TouBiZhaoLingSearch(string startDate, string endDate, int page, int rows)
{
int totalCount;
DataTable dt = cashDal.GetListAll(startDate, endDate, rows, page, out totalCount); Dictionary<string, object> dic = new Dictionary<string, object>();
List<object> list = new List<object>();
foreach (DataRow dr in dt.Rows)
{
Dictionary<string, object> item = new Dictionary<string, object>();
item.Add("id", dr["id"].ToString());
item.Add("addTime", dr["addTime"].ToString());
item.Add("orderId", dr["orderId"].ToString());
item.Add("userName", dr["userName"].ToString());
item.Add("opera", "");
list.Add(item);
} dic["total"] = totalCount;
dic["rows"] = list;
return Content(JsonConvert.SerializeObject(dic));
}
04-28 01:26