首页 > 代码库 > 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));}
EasyUI的datagrid分页
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。