David
David

Reputation: 51

Primefaces datatable selects unchecked checkbox rows

Hi I was using JSF datatable as follows

    <p:dataTable id="group"
       styleClass="table table-striped table-bordered"
       rowSelectMode="checkbox"
       value="#{importIssueController.impIssueStatusArrList}"
       selection="#{importIssueController.selectedIssues}"
       paginator="true" rows="10"
       paginatorTemplate="{CurrentPageReport}  {FirstPageLink}         
       {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
       rowsPerPageTemplate="2,10,15" lazy="true" var="importIssue" rowKey="#{importIssue[0]}">
       <p:column selectionMode="multiple" 
       disabledSelection="#{importIssue[6] == 'yes'}"
       style="width:16px;text-align:center"/>

here some row checkbox are disabled on some condition and user can select rows with enabled checkboxes. The problem I am facing here is even if checkbox is disabled and I click on the row and press submit the row is selected. Is there a way i can handle this ? I am using Primefaces 3.5

Upvotes: 1

Views: 736

Answers (1)

Suyash
Suyash

Reputation: 341

in your DataTable use the following

<p:column selectionMode="multiple"
    styleClass="#{importIssue[6] == 'yes' ? 'selectionDisabled':''}" />

And make changes in css

td.selectionDisabled .ui-chkbox{
    display: none;
   }

This will hide the checkbox completely for that condition. Use PF 5 instead of 3.5

Upvotes: 1

Related Questions