datatables接口
/*资源表格接口*/
var dataTableHeader=function(elem,unSorts,defaultSort,screens,status,toggleVis,ipAddress,stateSave,model,columnTitle,unOrderFlag,unPagingInfo){
resTableRadioRow=[];
//elem目标元素选择器
//unSorts无排序功能列,以Arry格式传入列索引
//defaultSort默认降序排序列
//screens枚举列索引
//status枚举内容,这个是表格列中要有
//toggleVis需要进行显示隐藏的列
//ipAddress需要进行排序的ip地址,列索引,eg:[1,2]
//model模态框中列表每页显示的5条数据
//columnTitle表格列添加title
//unOrderFlag表格不开启排序标识
//unPagingInfo表格无分页信息标识
var keyName='DataTables_'+elem.replace(/#|\./g,"")+'-'+window.location.pathname;
if(keyname && !(stateSave && stateSave===true){
localStore.removeItem(keyName);
}
var table=$(elem).DataTable({
stateSave:true,
destroy:true,
ordering:(function(){//是否开启排序功能
if(unOrderFlag){
return false;
}
})();
paging:(function(){
if(unPagingInfo){
return false;
}else{
return true;
}
})(),
dom:(function(){//是否有分页信息
if(unPagingInfo){
return "t<'bottom clearfix cloudos-table-tfoot'>";
}else{
return "t<'bottom clearfix cloudos-table-tfoot'lip>";
}
})();
createdRow:function(row,data,dataIndex){//当tr元素被创建(所有td内容已经被插入)该回调函数被执行
resTableRadioRow.push(row);
},
initComplete:function(settings){
var useId=getCookie("useId");,
api=this.api(),
tdCollection=api.columns(columnTitle).nodes();
for(var i=0;i<j<tdCollection.length;i++){
for(var j=0;j<tdCollection[i].length;j++){
if(!$(tdCollection[i][j].hasClass("cloudos-operate")){
$(tdCollection[i][j]).attr("title",$.trim($(tdCollection[i][j]).text()).replace(/[ ]/g,"").replace(/[\r\n]/g,""))
}
}
}
function getCookie(cookie_name){//获取用户id
var allcookies=document.cookie,
cookie_pos=allcookies.indexOf(cookie_name);//索引长度
if(cookie_pos!=-1){
//把cookie_pos放在值的开始,只要给值加1即可
cookie_pos+=cookie_name.length+1;
var cookie_end=allcookies.indexOf(":",cookie_pos);
if(cookie_end==-1){
cookie_end=allcookies.length;
}
var value=unescape(allcookies.substring(cookie_pos,cookie_end));
}
return value;
}