I need to add checkboxes to every column header in a <rich:dataTable>. A selected checkbox means the corresponding column will be included in a pdf report to be generated from the table data. Additional requirements are: the columns must be sortable and I must be able to mix <rich:column> and <rich:columns> tags.
I've tried to accomplish this a couple different ways. If I use <rich:columnGroup> like this:
<rich:dataTable>
  <f:facet name="header">
    <rich:columnGroup>
      <rich:column sortBy="#{bean.foo}">
        <h:outputText value="bar"/>
        <h:selectBooleanCheckbox value=.../>
      </rich:column>
      <rich:columns ...>
        <h:outputText value="bar"/>
        <h:selectBooleanCheckbox value=.../>
      </rich:columns>
    </rich:columnGroup>
  </f:facet>
  <rich:column>
    <h:outputText value="#{bean.baz}"/>
  </rich:column>
  <rich:columns value=... var=...>
    <h:outputText value="#{bean.foobar}"/>
  </rich:columns>
</rich:dataTable>
Then the sorting icon does not show. Alternatively, I've tried putting the text and the checkbox inside a <h:panelGroup>, such as this:
<rich:dataTable>
  <rich:column sortBy="#{bean.foo}">
    <f:facet name="header">
      <h:panelGroup layout="block">
        <h:outputText value="bar"/>
        <h:selectBooleanCheckbox value=.../>
      </h:panelGroup>
    </f:facet>
    <h:outputText value="#{bean.baz}"/>
  </rich:column>
  <rich:columns ...>
    <f:facet name="header">
      <h:panelGroup layout="block">
        <h:outputText value="bar"/>
        <h:selectBooleanCheckbox value=.../>
      </h:panelGroup>
    </f:facet>
    <h:outputText value="#{bean.foobar}"/>
  </rich:columns>
</rich:dataTable>
This way everything is shown, but when I click the checkbox it triggers column sorting, which is not what I want.
I've searched online for an answer on the but found nothing exactly like my problem. Does anyone know of a better way to do something li开发者_JAVA技巧ke this or at least how to avoid the sorting when I click the checkbox in the second code example?
Thank you very much.
Have you tried to use this kind of header :
<rich:columns value="#{bean.columns}" var="#{column}">
    <rich:column>
        <f:facet name="header">
            <h:panelGroup>
                <h:outputText value="#{column.title}" />
                <br />
                <h:selectBooleanCheckbox value="#{column.selected}" />
            </h:panelGroup>
        </f:facet>
        <!-- Column data -->
    </rich:column>
</rich:columns>
Note I'm now with RichFaces 4.0.0 / JSF 2.0 so the rich:columns doesn't exists anymore but can be replaced by c:forEach. Hope this helps!
Alex.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论