Primefaces数据表中选择未选中的复选框行

问题描述:

您好我使用JSF数据表如下Primefaces数据表中选择未选中的复选框行

<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"/> 

这里有一排复选框是一些条件,用户可以禁用启用复选框选择行。 我在这里面临的问题是,即使复选框被禁用,我点击行并按提交行被选中。有什么办法可以解决这个问题吗? 我使用Primefaces 3.5

+0

什么是importIssue [6]的数据类型?字符串还是布尔值? – lastresort

+0

importIssue [6]是字符串类型 – David

+0

您可以像这样捕获rowSelectEvent:http://www.kianworknotes.com/2014/10/how-to-disable-row-selection-in.html – lastresort

在你的数据表使用以下

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

而且在CSS

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

更改这将彻底隐藏复选框这一条件。使用PF 5而不是3.5