DataTable 两种ajax方式

前端之家收集整理的这篇文章主要介绍了DataTable 两种ajax方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//这个数据是如果不存在就补上位,要不JS会出错
$tmp_set = array('name'=>'','telnet'=>0,'ssh'=>0,'model'=>'');
foreach($tmpex as $k => $v)
{
$_id = array_search($v,$tmpsw) ;

$list_ex[$k] += $_id ? $list_sw[$_id] : $tmp_set ;

$list_ex[$k]['id'] = sprintf("%04d",$k+1);
$list_ex[$k]['iplong'] = long2ip($list_ex[$k]['iplong']);
$list_ex[$k]['status'] = is_status($list_ex[$k]['status']);
$list_ex[$k]['succeed'] = set_k($list_ex[$k]['succeed']).' / '.set_k($list_ex[$k]['fail']);
unset($list_ex[$k]['fail']);
$list_ex[$k]['name'] = banregion($list_ex[$k]['name']);
$list_ex[$k]['telnet'] = is_telnet($list_ex[$k]['telnet']).is_ssh($list_ex[$k]['ssh']);
unset($list_ex[$k]['ssh']);
//1$tmp[] = implode('","',$list_ex[$k]) ;//手动整理方式
}
//dump(json_encode($list_ex));
//1$result = '{"data": [["'.implode('"],["',$tmp).'"]]}'; //手动整理方式


//2$result['data'] = $list_ex; //json方式


Fctext('ipex'.I('id'),json_encode($result),TEMP_PATH);
//dump($a);

$this->assign('list',$list);

$this->assign('filename','ipex'.I('id').'.txt');



var t = $('#ajaxtable_em').DataTable({ "ajax": "../../Runtime/Temp/{$filename}","columns": [ { "className": 'details-control',"orderable": false,"data": null,"defaultContent": '' },{ "data": "iplong"},{ "data": "status" },{ "data": "succeed" },{ "data": "model" },{ "data": "name" },{ "data": function ( row,type,val,Meta ){ //可在这加一些属性 return row['telnet'] ; } } ],columnDefs:[{ orderable:false,//禁用排序 targets:[0] //指定的列 }],//"scrollY": "400px",// "scrollCollapse": true,// "paging": false,"pagingType": "full_numbers",//自动保存状态 stateSave: true,iDisplayLength :100,"oLanguage": { "sLengthMenu": "每页显示 _MENU_ 条记录","sZeroRecords": "对不起,查询不到任何相关数据","sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录","sInfoEmtpy": "找不到相关数据","sInfoFiltered": "数据表中共为 _MAX_ 条记录)","sProcessing": "正在加载中...","sSearch": "搜索","sUrl": "",//多语言配置文件,可将oLanguage的设置放在一个txt文件中,例:Javascript/datatable/dtCH.txt "oPaginate": { "sFirst": "第一页","sPrevIoUs": " 上一页 ","sNext": " 下一页 ","sLast": " 最后一页 " } } //多语言配置 }); $('#ajaxtable_em tbody').on('click','td.details-control',function () { var tr = $(this).closest('tr'); var row = t.row( tr ); if ( row.child.isShown() ) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child( format(row.data()) ).show(); tr.addClass('shown'); } } );

原文链接:https://www.f2er.com/ajax/162840.html

猜你在找的Ajax相关文章