简体   繁体   中英

Datatable multiple selection primefaces

I am trying to do a multiple selection table just like in this example here Showcase

The problem is that the column with checkboxes does not appear and I do not understand why

xhtml here

<h:form id="statusForm">
        <p:dataTable var="statusRow" value="#{displayTStatusRecords.tStatusLazyModel}"
             selection="#{displayTStatusRecords.selectedRecords}"
             paginator="true" rows="100"
             rowKey="#{statusRow.timestamp}"         
             paginatorTemplate=
                     "{RowsPerPageDropdown} {FirstPageLink}
                     {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
             rowsPerPageTemplate="100" lazy="true" widgetVar="statusWidget">      

             <p:ajax event="rowSelectCheckbox" update="@form"/>
             
             <!-- <p:ajax event="rowUnselect" listener="#{taskBean.onRowUnselect}" update="@form" />
             <p:ajax event="rowSelectCheckbox" listener="#{taskBean.onRowSelect}" update="@form" />
             <p:ajax event="rowUnselectCheckbox" listener="#{taskBean.onRowUnselect}" update="@form" />
             <p:ajax event="toggleSelect" update="@form"/> -->
             
              <p:column width="15px" headerText="Selection" selectionMode="multiple" classStyle="width:25px;text-align:center">
             </p:column> 
             
             <p:columns style="width:16px;text-align:center" var="attr" value="#{displayTStatusRecords.classFields}" filterBy="#{attr}" filterMatchMode="contains" width="200">
                <f:facet name="header">
                    <h:outputText
                        value="#{attr}" />
                </f:facet>
     
                <h:outputText value="#{statusRow[attr]}" />
                
                
             </p:columns>
            
                            
        </p:dataTable>
    </h:form>

The table has all the column with data except the checkbox one. it should also have one checkbox that will select all records on the page. Can someone help?

Edit: I noticed that <p:columns> overwrite the <p:column> I don't know why this happens

The problem was that I used

classStyle

instead of

style

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