本文主要是介绍Datatable的值设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
datatable初始化
table = $('#tableId').DataTable({//表格初始化"bDestroy":true,//清空数据"bRetrieve": true,//是否允许重新生成数据"stateSave":false,//不记忆页码"autoWidth": false,"deferRender": true,//延迟渲染"processing": false,"serverSide": true,"aLengthMenu": [[15, 30, 50, 100], ["15条", "30条", "50条", "100条"]],"filter":true,"ScrollCollapse":true,"scrollY":"auto","oLanguage": {"sEmptyTable": tip,},"ajax": {"beforeSend":function(){//加载过程进度条方法},"complete":function(){//加载结束方法},"url":********,"data":{"name":"FFFF","age":function(){var age=$("#age").val();return age;}}},"order": [[ 3, "desc" ]],"columnDefs": [{ "data":null,"name": "age", "targets": [0, 0],"orderable": false,"render":function(data,type,full){var keyStr="******";if(data.age<0){keyStr=0;}return keyStr},"width":50},{ "data":null,"name": "depart", "targets": [0, 1],"orderable": true,"render":function(data,type,full){return data.depart},"width":50},{ "data":null,"name": "name", "targets": [0, 2],"orderable": true,"render":function(data,type,full){return "<span>"+data.name+"</span>"},"width":300},{ "data":null,"name": "creatTime", "targets": [0, 3],"orderable": true,"render":function(data,type,full){return data.creatTime},"width":300},{"data":null,"name": "operator", "targets": [0, 4] ,"orderable": false,"render":function(data,type,full){return "<span class='operator ' id='"+data.id+"'></span>"},"width":100}],"fnDrawCallback": function(){callBackFunction();}});
浏览器发送数据
draw: 4
columns[0][data]:0
columns[0][name]:checked
columns[0][searchable]:false
columns[0][orderable]:false
columns[0][search][value]:
columns[0][search][regex]:false
columns[1][data]:1
columns[1][name]:index
columns[1][searchable]:false
columns[1][orderable]:false
columns[1][search][value]:
columns[1][search][regex]:false
columns[2][data]:2
columns[2][name]:user_name
columns[2][searchable]:true
columns[2][orderable]:true
columns[2][search][value]:
columns[2][search][regex]:false
columns[3][data]:3
columns[3][name]:name
columns[3][searchable]:true
columns[3][orderable]:true
columns[3][search][value]:
columns[3][search][regex]:false
order[0][column]:2
order[0][dir]:asc
start:0
length:20
search[value]:kkk 设置搜索值table.settings()[0].oPreviousSearch.sSearch=searchText;
search[regex]:false
_:1501036728929
内部属性值的设置格式
表名.settings()[0].属性名称(若属性为对象,内部具有属性值,则.属性值)=设置值
table.settings()[0].oLanguage.sEmptyTable=tip;设置表格为空时的提示语句
table.page.info().recordsTotal;获取记录的个数
var param = {
"searchText": “”,
};
table.settings()[0].ajax.data = param;设置datatable ajax请求参数
"searchText": “”,
};
table.settings()[0].ajax.data = param;设置datatable ajax请求参数
table.ajax.reload();表格重新加载
table.order()[0][0]:获取表格排序列索引;
table.order()[0][1]:获取表格排序列排序方式;desc或asc
这篇关于Datatable的值设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!