Jquery - DataTables [tableTools]:仅导出可见行 [英] Jquery - DataTables [tableTools]: export only visible rows
本文介绍了Jquery - DataTables [tableTools]:仅导出可见行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始使用jQuery DataTables。
I just started out using jQuery DataTables.
使用DataTables的tableTools,是否可以仅导出可见行而不是所有行?例如,如果分页设置为10,我预计只能导出10行。搜索结果也一样。
using the tableTools of DataTables, is it possible to only export visible rows instead of all the rows? If for example the pagination was set to 10 I would expect only 10 rows to be exported. The same goes for a search result.
这是代码的一部分:
$(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" ]]
} ) ;...
谢谢。
推荐答案
您可以通过在保存之前选择所有可见行来实现该行为,然后在保存完成后取消选择。
You can achieve that behavior by selecting all visible rows before saving, then deselecting them after saving completed.
$(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);
});
} );
这篇关于Jquery - DataTables [tableTools]:仅导出可见行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文