码迷,mamicode.com
首页 > 其他好文 > 详细

EasyUI的datagrid分页

时间:2014-12-20 22:05:41      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:

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>
View Code

后台:

技术分享
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));
}
View Code

 

EasyUI的datagrid分页

标签:

原文地址:http://www.cnblogs.com/s0611163/p/4175670.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!