1

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

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

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

4

1 回答 1

0

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

$(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");            
 }
 } );
于 2013-04-30T12:15:00.527 回答