如何显示和隐藏使用datatable jquery的列 [英] how to show and hide columns of using datatable jquery
本文介绍了如何显示和隐藏使用datatable jquery的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在进行javascript测试后显示和隐藏数据表的列,但它不能正常工作。
I need to show and hide the columns of the datatable after doing a javascript test, but it doesn't work good.
这是我的测试javascript:
This is my test javascript:
if ( $('#commune_to_display').val()==""){
$('#utable td:nth-child(2)').hide();
$('#commune_to ').hide();
}
在分页后,此测试仅适用于数据表的第一页仍然可见。
This test works just in the first page of the datatable, after pagination the column is still visible.
我该如何解决?感谢您的帮助
How can I fix it? thanks for help
推荐答案
您可以显示/隐藏列,如下所示。只需用您的实际列索引替换 3
和 4
。
You can show/hide columns as shown below. Just replace 3
and 4
with your actual column indexes.
var table = $('#utable').DataTable();
table.column(3).visible(true); // To show
table.column(4).visible(false); // To hide
这篇关于如何显示和隐藏使用datatable jquery的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文