简体   繁体   English

Primefaces columnToggler从复选框列表中删除项目

[英]Primefaces columnToggler remove item from checkbox list

I'm using a Primefaces columnToggler to dynamically hide/display columns in a data table. 我正在使用Primefaces columnToggler动态隐藏/显示数据表中的列。 This is working as expected, however I would like to remove items from the togglers checklist, so the user cannot check/uncheck them. 这按预期工作,但是我想从切换器清单中删除项目,因此用户无法选中/取消选中它们。

relevant code: 相关代码:

button and columnToggler 按钮和列

<p:commandButton id="toggler" 
                 type="button" 
                 value="Columns" 
                 title="Show/Hide columns"/>
<p:columnToggler datasource="my_datatable" 
                 trigger="toggler" />

dataTable dataTable的

 <p:dataTable value="#{bean.foobars}" var="fb" 
              id="my_datatable"> ...

column to show (working as expected) 要显示的列(按预期工作)

 <p:column headerText="Data One" >
      <h:outputText value="#{fb.data1}"/>
 </p:column>

column to hide from columnToggler checklist (how do I do this?) 要从columnToggler清单中隐藏的列(我该怎么做?)

 <p:column headerText="Always Available" >
      <h:outputText value="#{fb.mustSeeField}"/>
 </p:column>

I was hoping to find an attribute on p:columnToggler for 'locked' or 'always on' fields, or possibly an attribute on p:column to remove it from the columnToggler checklist. 我希望在p:columnToggler上找到一个“锁定”或“ always on”字段的属性,或者在p:column上找到一个属性,以将其从columnToggler清单中删除。 Unfortunately I'm not sure how to do this, or if it's possible. 不幸的是,我不确定如何执行此操作,或者是否可行。 Thoughts? 思考? Solutions? 解决方案? thank you! 谢谢!

PrimeFaces has a toggleable attribute on the p:column as can be seen in the PrimeFaces 6.1 documentation on page 110. So 如第110页的PrimeFaces 6.1文档所示,PrimeFaces在p:column上具有toggleable属性。

<p:column headerText="Always Available" toggleable="false">
   <h:outputText value="#{fb.mustSeeField}"/>
</p:column>

Should do the trick 应该做的把戏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM