我刚开始使用jQuery DataTables.
使用DataTables的tableTools,是否可以只导出可见行而不是所有行?例如,如果分页设置为10,我预计只会导出10行.搜索结果也是如此.
这是代码的一部分:
$(document).ready(function() { var table = $('#example').DataTable({ "pagingType": "full_numbers","iDisplayLength" : 10,dom: 'T<"clear">lfrtip',"oTableTools": { "aButtons": [ { "sExtends": "copy","mColumns": "visible","bSelectedOnly": true },{ "sExtends": "xls","mColumns": "visible" },{ "sExtends": "print","mColumns": "visible" } ],"sRowSelect": "multi"},"order": [[ 0,"asc" ]] } ) ;...
谢谢.
解决方法
您可以通过在保存之前选择所有可见行来实现该行为,然后在保存完成后取消选择它们.
$(document).ready(function() { $('#example').DataTable( { dom: 'T<"clear">lfrtip',"oTableTools": { "sRowSelect": "multi","aButtons": [ { "sExtends": "csv","bSelectedOnly": true,"fnComplete": function ( nButton,oConfig,oFlash,sFlash ) { var oTT = TableTools.fnGetInstance( 'example' ); var nRow = $('#example tbody tr'); oTT.fnDeselect(nRow); } } ] } } ); $('a.DTTT_button_csv').mousedown(function(){ var oTT = TableTools.fnGetInstance( 'example' ); var nRow = $('#example tbody tr'); oTT.fnSelect(nRow); }); } );