topjui/easyui 表格分页简单实例

$('#dg').datagrid({

rownumbers:true, //行号

singleSelect:true, //单选

autoRowHeight:false, //自动行高

pagination:true, //显示表格下面的分页插件

fitColumns:true, //字段自动分配

collapsible:true, //表单收缩

checkOnSelect : false,

toolbar:'#tb', //显示表格上面的搜索框等,这些按钮在tb这个div里

url:'${ctx}/....',//表格数据的请求路径(由后台提供;注意是里面有rows的数组,带total的对象数据,否则无法直接显示,大家模拟数据的时候要注意)

pageNumber:1, //默认显示第几页

pageSize: 2,//每页显示的记录条数,默认为10

pageList: [2,4,6,8],//可以设置每页记录条数的列表

columns:[[

{field:'id',title:'名称',hidden:true},

{field:'opr',title: '操作',align: 'center',width:'25%',

  formatter:function(value,row,index){//格式化

     if(row.id) {//条件根据实际情况修改

        return

             "&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' οnclick='modify(\""+ row.id +"\",\""+index+"\")'>修改</a>"+

             "&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' οnclick='del(\""+ row.id +"\",\""+index+"\")'>删除</a>";

        }

     }

  }

}]]

});

//设置分页控件

var p = $('#dg').datagrid('getPager');

$(p).pagination({

beforePageText: '第',//页数文本框前显示的汉字

afterPageText: '页 共 {pages} 页',

displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',

});

//如果前端要模拟数据怎么办,json数据就是这个样子

{

"rows": [

{"id":1,"opr": 1},

{"id":2,"opr": 2},

...

],

"total": 100

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值