【问题标题】:JQuery DataTable HideColumnJQuery 数据表隐藏列
【发布时间】:2013-04-29 09:32:41
【问题描述】:

我在 Java Struts 应用程序中使用 DataTable 插件来显示列表数据屏幕。我在其中向用户添加了数据表的显示/隐藏列工具。此外,某些列具有用于列表中更新详细信息的文本输入。 但是当我提交表单时,用户需要更新列表。动作类将被调用。在操作类中,我能够获取表数据,但数据只有可见列数据而不是隐藏列。对于业务验证,我还需要隐藏列。

实际上,当我隐藏 DOM 中不可用的列时

任何人都可以建议我什么是解决方案。

【问题讨论】:

  • 请发布相关代码...
  • 答案可能在插件文档中

标签: java jquery datatables


【解决方案1】:

您可以使用以下功能隐藏列:

$(document).ready(function() {
$('#example').dataTable( {
} );
} );

function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object    */
 var oTable = $('#example').dataTable();

var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}

或者您可以使用fnDrawCallback 来执行此操作,例如:

$('#example').dataTable( {
 "fnDrawCallback": function () {
     //Hide Column 1
     $("#example tbody tr td:nth-child(1)").css("display", "none");
     $("#example thead tr th:nth-child(1)").css("display", "none");            
 }
 } );

【讨论】:

    猜你喜欢
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多