jquery easyui datagrid 分页 详解

由于项目原因,用了jquery easyui 感觉界面不错,皮肤样式少点,可是官网最近打不开了,资料比较少,给的demo没有想要的效果,今天在用datagrid 做分页显示的时候,折腾了半天,网上的资料也比较少,后自己动手,终于解决,废话不说,开始:

datagrid分页 有一个附加的分页控件,只需后台获取分页控件自动提交的两个参数rows每页显示的记录数和page;//当前第几页

然后读取相应页数的记录,和总记录数total一块返回即可 界面如下:




1、下边是datagrid的显示对话框,我直接用table把列头显示出来,感觉比用js写要易于阅读

<table id="list_data" cellspacing="0" cellpadding="0">  
    <thead>  
        <tr>  
            <th field="fldAppDept" width="100">部门</th>  
            <th field="fldAppNode" width="100">网站</th>  
            <th field="fldAppName" width="100">名称</th>  
            <th field="fldAppMgr" width="100">管理员</th>  
            <th field="fldAppNote" width="100">注释</th>  
            <th field="fldAppType" width="100">类型</th>  
            <th field="fldTelphone" width="100">电话</th>  
            <th field="fldAppImg" width="100">职务</th>  
            <th field="fldAppMonitor" width="100">启用监测</th>  
            <th field="fldAppLevel" width="100">要重级别</th>  
        </tr>  
    </thead>  
</table>

2、js代码,用于构建datagrid

注意 要想显示分页控件,pagination属性必须为true

//datagrid初始化  
    $('#list_data').datagrid({  
        title:'应用系统列表',  
        iconCls:'icon-edit',//图标  
        width: 700,  
        height: 'auto',  
        nowrap: false,  
        striped: true,  
        border: true,  
        collapsible:false,//是否可折叠的  
        fit: true,//自动大小  
        url:'listApp.action',  
        //sortName: 'code',  
        //sortOrder: 'desc',  
        remoteSort:false,   
        idField:'fldId',  
        singleSelect:false,//是否单选  
        pagination:true,//分页控件  
        rownumbers:true,//行号  
        frozenColumns:[[  
            {field:'ck',checkbox:true}  
        ]],  
        toolbar: [{  
            text: '添加',  
            iconCls: 'icon-add',  
            handler: function() {  
                openDialog("add_dialog","add");  
            }  
        }, '-', {  
            text: '修改',  
            iconCls: 'icon-edit',  
            handler: function() {  
                openDialog("add_dialog","edit");  
            }  
        }, '-',{  
            text: '删除',  
            iconCls: 'icon-remove',  
            handler: function(){  
                delAppInfo();  
            }  
        }],  
    });  
    //设置分页控件  
    var p = $('#list_data').datagrid('getPager');  
    $(p).pagination({  
        pageSize: 10,//每页显示的记录条数,默认为10  
        pageList: [5,10,15],//可以设置每页记录条数的列表  
        beforePageText: '第',//页数文本框前显示的汉字  
        afterPageText: '页    共 {pages} 页',  
        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
        /*onBeforeRefresh:function(){ 
            $(this).pagination('loading'); 
            alert('before refresh'); 
            $(this).pagination('loaded'); 
        }*/ 
    });



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值