大佬教程收集整理的这篇文章主要介绍了jquery – 使用服务器端处理隐藏DataTable的JSON中存在的列,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<script type="text/javascript"> $(function () { $('#example').dataTable({ 'bProcessing': true,'bServerSide': true,'sAjaxSource': '/data.ashx' }); }); </script>
我的JSON是这样的:
{ "iTotalRecords": "57","iTotalDisplayRecords": "57","aaData": [ [ "id001","Name001","Addr001",],[ "id002","Name002","Addr002",] ] }
我想实现如下:
<table id="datatable"> <thead>...</thead> <tbody> <tr id="id001"> <td>Name001</td> <td>Addr001</td> </tr> <tr id="id002"> <td>Name002</td> <td>Addr002</td> </tr> . . </tbody> </table>
注意:
要将ID分配给< tr>我在用:
"fnRowCallback": function( nRow,aData,iDisplayIndex,iDisplayIndexFull) { $(nRow).attr("id",aData[0]); return nRow; }
但它并没有隐藏ID列.
请帮忙.
更新:
我找到了解决问题的完美解决方案.
我必须创建我的JSON,如下所示
{ "iTotalRecords": "57","aaData": [ [ "0":"Name001","1":"Addr001","DT_RowId": "id001",[ "0":"Name002","1":"Addr002","DT_RowId": "id002",] ] }
有关更多信息,请访问此链接:DateTable – automatic row ID addition
$('#datatable').dataTable({ aaData: aaData,"fnRowCallback": function(nRow,iDisplayIndexFull) { //console.log(nRow); $(nRow).attr("id",aData[0]); return nRow; },"aoColumnDefs": [ { "bSearchable": false,"bVisible": false,"aTargets": [0] },] });
工作fiddle
以上是大佬教程为你收集整理的jquery – 使用服务器端处理隐藏DataTable的JSON中存在的列全部内容,希望文章能够帮你解决jquery – 使用服务器端处理隐藏DataTable的JSON中存在的列所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。