简体   繁体   中英

Primefaces columnToggler remove item from checkbox list

I'm using a Primefaces columnToggler to dynamically hide/display columns in a data table. 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

 <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?)

 <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. 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

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

Should do the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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