Javascript 引导表条件显示/隐藏列
我需要显示/隐藏引导表中的列。如果一个条件是真的,我想展示一些柱和隐藏一些其他。 我尝试了各种方法,但没有成功 我使用Javascript 引导表条件显示/隐藏列,javascript,thymeleaf,bootstrap-table,Javascript,Thymeleaf,Bootstrap Table,我需要显示/隐藏引导表中的列。如果一个条件是真的,我想展示一些柱和隐藏一些其他。 我尝试了各种方法,但没有成功 我使用thymeleaf查看视图 这是我的html页面代码: 我的桌子: <table data-toggle="table" th:data-url="@{/certificato/list/{idCommessa}(idCommessa=${commessa.id})}" data-pagination="true"
thymeleaf
查看视图
这是我的html页面代码:
我的桌子:
<table data-toggle="table"
th:data-url="@{/certificato/list/{idCommessa}(idCommessa=${commessa.id})}"
data-pagination="true"
data-search="true"
data-classes="table table-hover"
data-striped="true" id="tableCertificato"
data-side-pagination="client">
<thead>
<tr>
<th data-sortable="true" data-field="numeroCertificato" th:text="#{numeroCertificato}"></th>
<th data-sortable="true" data-field="dataCertificato" th:text="#{dataCertificato}" data-formatter="dateFormatter"></th>
<th data-field="nFabbrica" th:text="#{nFabbrica}" ></th>
<th data-field="modulo" th:text="#{modulo}" ></th>
<th data-field="categoriaRischio" th:text="#{categoriaRischio}"></th>
</thead>
条件为真,我用一条警告消息对其进行了调试。
但“隐藏/显示”列不会运行。列始终显示
我尝试更改代码但未成功,因此:
<th th:if="${commessa.tipoAttivita != 'TPED' }" data-field="nFabbrica" th:text="#{nFabbrica}"></th>
并使用条件数据可见
。
同样的结果
有人能帮我吗?我遇到了类似的问题,我已通过以下步骤解决:
data visible=“false”
李>
$table=$('#tableCertificato').bootstrapTable({})
并在if语句中使用:
$table = $('#tableCertificato').bootstrapTable({ });
if(tipoCertVar != 'TPED') {
$table.bootstrapTable('showColumn', 'nFabbrica');
$table.bootstrapTable('showColumn', 'modulo');
$table.bootstrapTable('showColumn', 'categoriaRischio');
}
我希望这个解决方案能对你有所帮助 谢谢,我跑了!
$table = $('#tableCertificato').bootstrapTable({ });
if(tipoCertVar != 'TPED') {
$table.bootstrapTable('showColumn', 'nFabbrica');
$table.bootstrapTable('showColumn', 'modulo');
$table.bootstrapTable('showColumn', 'categoriaRischio');
}