获取某一列的全部数据
var api=this.api();
areas=api.column(0).data();
pos=api.column(1).data();
有时候 $(‘#example‘).dataTable 小写时也还需要api
render中的row里面包含的数据是当前行里面所有的数据
render:function(data,type,row)
老版本与新版本ajax写法
ajax:{老版本
"type":"post",
"url":url,
"dataSrc": function (mdata) {
if(mdata.total){
sessionStorage.setItem("totalCount",mdata.total);
}
return mdata.data;
}
},
option一些参数配置意思
"displayLength" : 10,//显示条数
"deferRender": true,//大数据量处理,加快速度;
"processing": true,
"destroy": true,
"retrieve":true,
language:
"processing": "正在加载数据...",
"loadingRecords":" ",如果没有加载到数据的 话 就啥都不提示,默认是:“没有找到数据”
// "sZeroRecords": "抱歉, 没有找到",
"infoEmpty": "无记录",
"decimal":",",
"thousands":".",
"paginate": {
"previous": "上一页",
"next": "下一页",
"first": "首页",
"last": "尾页"
}
自定义事件
// var eventFired = function(type) {
//
// if(type=="翻页"){
// var b=$(‘body‘)[0];
// b.style.backgroundColor="red";
// console.log(‘aaaa‘);
//
// console.log(‘cccc‘);
// }
// }
// $(‘#table_id_example‘).on(‘order.dt‘,
// function() {
// eventFired(‘排序‘);
// }).on(‘search.dt‘,
// function() {
// eventFired(‘搜索‘);
// }).on(‘page.dt‘,
// function() {
/ / eventFired(‘翻页‘);
// }).dataTable();
原文:http://www.cnblogs.com/zjpzjp/p/6387532.html