注意这段代码:
{"data" : 'KeyId',
"render" : function(data, type, full, meta){
if(meta.settings && meta.settings.aLastSort){
if(meta.settings.aaSorting[0][1] == 'asc'){
return meta.row + 1 + meta.settings._iDisplayStart;
}else if(meta.settings.aaSorting[0][1] == 'desc'){
//倒序
return (meta.settings.aiDisplay.length-meta.row) + meta.settings._iDisplayStart;
}
}
}},
//禁止alert显示警告和错误
var _wh__Table___;
initData();
$.fn.dataTable.ext.errMode = 'none'; //不显示任何错误信息
function initData(){
//datatables
_wh__Table___ = $("#tab_orderList").dataTable({
"destroy" : true, //销毁表格对象
"aLengthMenu":[10,25,50,100,500,1000,2500], //用户可自选每页展示数量
"searching":true,//禁用搜索(搜索框)
"lengthChange":true,
"paging": true,//开启表格分页
"bProcessing" : true,
"bServerSide" : true,
"bAutoWidth" : false,
"sort":"position",
"deferRender":true,//延迟渲染
"bStateSave" : true, //在第三页刷新页面,会自动到第一页
"retrieve" : false, //类似单例模式,重复利用以存在对象。
"iDisplayLength" :10,
"iDisplayStart" : 0,
"bRetrieve": false,
"select": {
style: 'os',
selector: 'td:first-child'
},
"ordering": true,//全局禁用排序
"ajax": { //ajax方式向后台发送请求
"type": "POST",
"url":"URL?t="+new Date().getTime(),
"dataType" : "json",
"data": function ( d ) {//重新初始化变化了的参数
}
},
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0 ] },{ "bSortable": false, "aTargets": [ 8 ] }],//第0,8不要排序
columns: [
{ data: 'KeyId',
"render": function ( data, type, full, meta ) {
return ''+
'';
}},
/* { data: 'KeyId' ,
"render": function ( data, type, full, meta ) {
return meta.row + 1;
}}, */
{"data" : 'KeyId',
"render" : function(data, type, full, meta){
if(meta.settings && meta.settings.aLastSort){
if(meta.settings.aaSorting[0][1] == 'asc'){
return meta.row + 1 + meta.settings._iDisplayStart;
}else if(meta.settings.aaSorting[0][1] == 'desc'){
//倒序
return (meta.settings.aiDisplay.length-meta.row) + meta.settings._iDisplayStart;
}
}
}},
{ data: 'VideoName' },
{ data: 'CourseName'},
{ data: 'TeacherName'},
{ data: 'IsDisabled',
"render": function ( data, type, full, meta ) {
return ''+(data == 1 ? "禁用":"启用")+'';
}},
{ data: 'UserName'},
{ data: 'AddTime'},
{ data: 'id' ,
'render':function(data, type, full, meta){
//var del="defiles('"+item.Guid+"')";
//var edit="editfiles('"+item.Guid+"','"+item.CompanyGuid+"')";
//html+='';
var html ='';
html+='';
html+=' 编辑';
html+='';
html+='';
html+=' 预览';
html+='';
html+='';
html+=' 删除';
html+='';
html+='';
//html+=' ';
return html;
}
},
],
"oLanguage" : { // 国际化配置
"sProcessing" : "正在获取数据,请稍后...",
"sLengthMenu" : "显示 _MENU_ 条",
"sZeroRecords" : "没有找到数据",
"sInfo" : "从 _START_ 到 _END_ 条记录 总记录数为 _TOTAL_ 条",
"sInfoEmpty" : "记录数为0",
"sInfoFiltered" : "(全部记录数 _MAX_ 条)",
"sInfoPostFix" : "",
"sSearch" : "",
"sUrl" : "",
"oPaginate" : {
"sFirst" : "第一页",
"sPrevious" : "上一页",
"sNext" : "下一页",
"sLast" : "最后一页"
}
},
});
}