仅对几行禁用行选择-Primefaces [英] Disable row selection for a few rows only - Primefaces
问题描述
我想知道是否有一种方法可以基于bean属性对Primefaces中给定的一组行禁用基于无线电的行选择.
I would like to know if there is a way of disabling the radio-based row selection for a given set of rows in Primefaces, based on a bean property.
示例:
<p:dataTable var="foo" value="#{bean.foos}" selection="#{bean.selectedFoo}">`
<p:column selectionMode="single" />
<p:column>
<h:outputText value="#{foo.bar}" />
</p:column>
<p:dataTable>
在这种情况下,想象一下我想通过禁用行来禁用foo.bar == 1,5,10
所在的行,我的意思是禁用与该行关联的单选按钮.
In this case, imagine I would like to disable the rows where foo.bar == 1,5,10
, by disabling the rows I mean disable the radio button associated with the row.
我想不出一种方法来实现...任何想法?甚至css + javascript hack解决方案也是可以接受的.
I couldn't figure out a way of accomplish that... any ideas? Even a css + javascript hack solution would be acceptable.
推荐答案
从4.0版本开始,Primefaces数据表带有disabledSelection
属性.
Since 4.0 version, Primefaces datatable comes with a disabledSelection
property.
<p:dataTable var="foo" value="#{bean.foos}" selection="#{bean.selectedFoo}" disabledSelection="#{foo.bar == 1}">
<p:column selectionMode="single" />
<p:column>
<h:outputText value="#{foo.bar}" />
</p:column>
<p:dataTable>
然后,当foo.bar == 1
为true时,复选框将被禁用.
Then, when foo.bar == 1
is true, checkbox will be disabled.
这篇关于仅对几行禁用行选择-Primefaces的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!