jquery datatable分页配置
2013-11-20 09:58
477 查看
//点击查询
oTable.fnPageChange( 'previous', true );
var oTable = $('#sample_2').dataTable( {
"aLengthMenu":[10,15,20,30],
//分页下拉
//"iDisplayLength":3,
//每页显示条数 客户端有效
//"iTotalRecords":,
//当datatable获取数据时候是否显示正在处理提示信息
//"iTotalDisplayRecords":,
//
//"sPaginationType":"",
"bFilter": false, //是否启用客户端过滤器
"bSort": false, //排序功能
"bInfo": true,//页脚信息
//"bAutoWidth": true//自动宽度
//"bStateSave": true,//分页cookie保存数据
//"oSearch":{ "sSearch": "aa","bRegex": false, "bSmart": true },
"bProcessing": true,//数据加载提示
"bServerSide": true,//数据加载方式[从服务器加载]
"sAjaxSource": "userTable.html",
"sServerMethod": "POST",
"aoColumns": [
{ "mData": "id" },
{ "mData": "email" },
{ "mData": "realname" },
{ "mData": "isSuperAdmin", "sClass": "center" },
{ "mData": "status" },
{ "mData": "languageName" },
{ "mData": "promptids" },
{ "mData": "gameids" },
{ "mDataProp": function(obj) {
var sReturn = "<input type='checkbox' name = 'userIds' value='"+obj["id"]+"'/>";
return sReturn;
}
}
],
//"aaSorting": [[1, 'asc']],//排序
//"aoColumnDefs": [{"bVisible": false,"aTargets": [3]}],//隐藏某些列
//"sDom": '<"H"lfr>t<"F"ip> ',
"fnServerParams": function (aoData) {
aoData.push( { "name": "id","value": id } );
aoData.push( { "name": "realname","value": realname } );
aoData.push( { "name": "email","value": email } );
aoData.push( { "name": "status","value": status } );
aoData.push( { "name": "languageId","value": languageId } );
},
"oLanguage": { //汉化
"sSearch": ["one","two"],
"sLengthMenu": "每页显示 _MENU_ 条记录",
"sZeroRecords": "没有检索到数据",
"sInfo": "当前数据为从第 _START_ 到第 _END_ 条数据;总共有 _TOTAL_ 条记录",
"sInfoEmtpy": "没有数据",
"sProcessing": "正在加载数据...",
"oPaginate":
{
"sFirst": "首页",
"sPrevious": "上一页",
"sNext": "下一页",
"sLast": "尾页"
}
}
} );
//显示隐藏列
$('#sample_2_column_toggler input[type="checkbox"]').change(function(){
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var iCol = parseInt($(this).attr("data-column"));
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis(iCol, (bVis ? false : true));
});
//html-----------------------------
<table id="sample_2" class="table table-striped table-bordered table-hover table-full-width">
<thead class="flip-content">
<tr>
<!-- <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_2 .checkboxes" /></th> -->
<th >ID</th>
<th >登录邮箱</th>
<th >实名</th>
<th >超级管理员</th>
<th >状态</th>
<th >语言</th>
<th >所属渠道</th>
<th >所属游戏</th>
<th><input type="checkbox" id="userCheckd" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
oTable.fnPageChange( 'previous', true );
var oTable = $('#sample_2').dataTable( {
"aLengthMenu":[10,15,20,30],
//分页下拉
//"iDisplayLength":3,
//每页显示条数 客户端有效
//"iTotalRecords":,
//当datatable获取数据时候是否显示正在处理提示信息
//"iTotalDisplayRecords":,
//
//"sPaginationType":"",
"bFilter": false, //是否启用客户端过滤器
"bSort": false, //排序功能
"bInfo": true,//页脚信息
//"bAutoWidth": true//自动宽度
//"bStateSave": true,//分页cookie保存数据
//"oSearch":{ "sSearch": "aa","bRegex": false, "bSmart": true },
"bProcessing": true,//数据加载提示
"bServerSide": true,//数据加载方式[从服务器加载]
"sAjaxSource": "userTable.html",
"sServerMethod": "POST",
"aoColumns": [
{ "mData": "id" },
{ "mData": "email" },
{ "mData": "realname" },
{ "mData": "isSuperAdmin", "sClass": "center" },
{ "mData": "status" },
{ "mData": "languageName" },
{ "mData": "promptids" },
{ "mData": "gameids" },
{ "mDataProp": function(obj) {
var sReturn = "<input type='checkbox' name = 'userIds' value='"+obj["id"]+"'/>";
return sReturn;
}
}
],
//"aaSorting": [[1, 'asc']],//排序
//"aoColumnDefs": [{"bVisible": false,"aTargets": [3]}],//隐藏某些列
//"sDom": '<"H"lfr>t<"F"ip> ',
"fnServerParams": function (aoData) {
aoData.push( { "name": "id","value": id } );
aoData.push( { "name": "realname","value": realname } );
aoData.push( { "name": "email","value": email } );
aoData.push( { "name": "status","value": status } );
aoData.push( { "name": "languageId","value": languageId } );
},
"oLanguage": { //汉化
"sSearch": ["one","two"],
"sLengthMenu": "每页显示 _MENU_ 条记录",
"sZeroRecords": "没有检索到数据",
"sInfo": "当前数据为从第 _START_ 到第 _END_ 条数据;总共有 _TOTAL_ 条记录",
"sInfoEmtpy": "没有数据",
"sProcessing": "正在加载数据...",
"oPaginate":
{
"sFirst": "首页",
"sPrevious": "上一页",
"sNext": "下一页",
"sLast": "尾页"
}
}
} );
//显示隐藏列
$('#sample_2_column_toggler input[type="checkbox"]').change(function(){
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var iCol = parseInt($(this).attr("data-column"));
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis(iCol, (bVis ? false : true));
});
//html-----------------------------
<table id="sample_2" class="table table-striped table-bordered table-hover table-full-width">
<thead class="flip-content">
<tr>
<!-- <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_2 .checkboxes" /></th> -->
<th >ID</th>
<th >登录邮箱</th>
<th >实名</th>
<th >超级管理员</th>
<th >状态</th>
<th >语言</th>
<th >所属渠道</th>
<th >所属游戏</th>
<th><input type="checkbox" id="userCheckd" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
相关文章推荐
- 使用jquery获取radio的值
- 实现在Android简单封装类似JQuery异步请求
- html引入样式表和js文件中间用逗号隔开是什么意思和(function($) {...})(jquery);的意思
- jquery简单可拖动可关闭的div
- 用jQuery与JSONP来解决跨域访问的问题
- jquery简单的多级下拉菜单
- jquery iframe操作详细解析
- jquery交替变换颜色的三种方法 实例代码
- 我的第一个jquery插件:下拉多选框
- jQuery 快速结束当前动画
- jquery iframe操作详细解析
- JQuery操作iframe父页面与子页面的元素与方法(实例讲解)
- jQuery 快速结束当前正在执行的动画
- jquery实现树形二级菜单实例代码
- jQuery对html元素取值与赋值的方法
- jQuery jcrop插件截图使用方法
- jquery实现可拖动DIV自定义保存到数据的实例
- jquery html动态生成select标签出问题的解决方法
- 关于jQuery ajax jsonp请求
- 26个Jquery使用小技巧