zoukankan      html  css  js  c++  java
  • 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: '日期',  100 },
                    {
                        field: 'orderId', title: '摘要',  100, formatter: function (value, rowData, rowIndex) {
                            return "订单号:" + rowData["orderId"];
                        }
                    },
                    { field: 'userName', title: '操作人',  100 },
                    { field: 'opera', title: '操作',  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
  • 相关阅读:
    【华为云技术分享】云小课 | 磁盘容量不够用?小课教你来扩容!
    什么时候用用value,什么时候用innerHTML?
    零碎知识点总结
    hnctf安恒--蜘蛛侠呀
    sqli-labs Less-11 and Less-12
    sql注入--基于报错的注入
    ‘百度杯’十月场web ---login
    “百度杯”CTF比赛 九月场---123
    百度杯 ctf 九月场---Text
    【迎圣诞,拿大奖】+流量分析+Writeup分享
  • 原文地址:https://www.cnblogs.com/s0611163/p/4175670.html
Copyright © 2011-2022 走看看