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请求参数
table.ajax.reload();表格重新加载


table.order()[0][0]:获取表格排序列索引;

table.order()[0][1]:获取表格排序列排序方式;desc或asc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三知之灵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值