【发布时间】:2015-07-12 05:45:19
【问题描述】:
我正在使用这个很棒的 jQuery Datatables 和 TableTools 扩展,除了打印之外,一切都很好。
我的页面上有一个侧边栏,所以当我单击“打印”时,侧边栏包含在打印视图中,这不好,所以我所做的就是在触发“打印”按钮上的单击事件时隐藏它,但我不知道怎么恢复侧边栏了
我可以使用.show() 和.hide(),但我只是不知道在哪里捕捉有人退出打印视图的事件(按Esc 将关闭打印视图)。
下面的代码是我尝试过的:
$(document).ready(function(){
//initialize datatables
$('#test_table').dataTable( {
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "/../../../plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf"
}
} );
//when they click the custom button that has a class of 'test_print' then trigger the datatables table tools button with a class of 'DTTT_button_print'
$(".test_print").click(function(){
$(".sidebar-toggle").hide(); //hide the sidebar
$(".DTTT_button_print").trigger("click"); //trigger the click event
});
});
如何捕捉关闭打印视图的事件(当按下 Esc 时打印视图将退出)以便我可以显示我的侧边栏?
【问题讨论】:
-
您能否在新窗口中打开打印视图(隐藏所有需要隐藏的内容)并使用侧边栏保留原始页面?这样您就不必查看打印视图何时关闭,因为它不会影响原始页面。
标签: javascript jquery datatables datatables-1.10