Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
200 views
in Technique[技术] by (71.8m points)

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

question from:https://stackoverflow.com/questions/66051540/datatable-multiple-selection-primefaces

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem was that I used

classStyle

instead of

style


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...