我正在从数据表中导出所有数据。现在我需要的是一个条件,如果条件为 true,则启用 oSelectorOpts
否则不启用。
这是我的配置代码:
"aButtons": [
{
"bFooter": false,
"fnClick": function ( nButton, oConfig ) {
if(condition)
{
"oSelectorOpts": { page: 'current' };
}
},
'sExtends':'xls',
"sFileName": "Telephone_Directory.xls",
'mColumns':[0,1,2,3]
},
为什么我需要这个,因为有时我会导出所有数据,有时仅导出当前页面数据。 有没有其他方法可以实现这一点。请提出建议。
最佳答案
这是我使用的东西,它为您提供 2 个按钮/选项,打印当前页面或打印全部:
"sDom": '<"clear">T<"clear">lfrtip',
"oTableTools": {
"aButtons": [
{
"sExtends": "print",
"sButtonText": "print page",
"bShowAll": false
},
{
"sExtends": "print",
"sButtonText": "print all",
"bShowAll": true
}
],
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.0/swf/copy_csv_xls_pdf.swf"
},
关于jquery - 基于条件的数据表 oSelectorOpts 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26112501/