jQuery DataTables隐藏列而不从DOM中删除它 [英] jQuery DataTables hide column without removing it from DOM
问题描述
我需要隐藏一列,以显示在jquery数据表中。
当我使用bVisible属性隐藏列时,它会从DOM中消失。
I need to hide a column from showing up in jquery datatables. When I hide the column using bVisible property it disappears from the DOM.
我想将列的表格单元格的display属性设置为none,值不会出现在视图中,但是它们仍然存在于DOM中,因为我隐藏的列唯一标识行,我需要知道行选择上的唯一ID。如何实现这个。
I want to set display property of table cells of a column to none so that the values do not appear in the view but they should still be present in the DOM as the column I am hiding identifies the row uniquely and I need to know the unique ID on row select. How to achieve this.
我使用服务器端分页的aaData属性填充表。
I am populating the table using aaData property using server side pagination.
看看这个问题,但这些选项从DOM中删除它。
jquery datatables隐藏列
Had a look at this question but these options remove it from the DOM. jquery datatables hide column
推荐答案
您应该使用 className
以及 columnDefs 或列,
请参阅以下示例(将自定义类分配到第一列):
See the following examples (assign custom class to first column):
$('#example').dataTable( {
"columnDefs": [
{ className: "hide_column", "targets": [ 0 ] }
]
} );
或
$('#example').dataTable( {
"columns": [
{ className: "hide_column" },
null,
null,
null,
null
]
} );
代码片段从这里
旧答案
尝试添加
"sClass": "hide_column"
并在你的css中定义 hide_column
/ p>
And define hide_column
class in your css like this
.hide_column{
display : none;
}
应该使该列隐藏...
that should make that column hidden...
这篇关于jQuery DataTables隐藏列而不从DOM中删除它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!