您的位置:首页 > Web前端 > JQuery

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: