简体   繁体   English

打印数据表作为默认表

[英]print datatable as default table

I have a datatable with column filter so thead has search inputs 我有一个带有列过滤器的数据表,因此该广告具有搜索输入

I need when user print this page (Cntr + p) to print the table as a default table without the column filter and datatable arrows "remove datatable" 我需要在用户打印此页(Cntr + p)时将表打印为默认表,而没有列过滤器和数据表箭头“删除数据表”

What you need to do in your css is define print media as follows with all the classes you want to apply or not apply when user hits Ctrl+P: 您需要在CSS中做的是定义打印介质,如下所示,当用户按下Ctrl + P时要应用或不应用的所有类:

Here is an example that will eliminate all arrows from column headers 这是一个示例,该示例将消除列标题中的所有箭头

@media print {
    .sorting, .sorting_asc, .sorting_desc {
        display:none;
    }
}

UPDATE: 更新:

In order for you to show filter text, I suggest you do the following: 为了显示过滤器文本,建议您执行以下操作:

  1. Add a hidden text field before your filter input (refer to this documentation on how to insert elements in datatables https://datatables.net/reference/option/dom ) 在过滤器输入之前添加一个隐藏的文本字段(请参阅此文档,了解如何在数据表中插入元素https://datatables.net/reference/option/dom
  2. Attach keyup binding to the filter input so that it populates your hidden text. 将keyup绑定附加到过滤器输入,以便它填充您的隐藏文本。 (refer to this example datatables global search on keypress of enter key instead of any key keypress ) (请参考此示例,数据表在Enter键而不是任何keypress上进行全局搜索
  3. In the @media print unhide the text box and hide the filter input box. 在@media打印中,取消隐藏文本框,然后隐藏过滤器输入框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM