How to disable item in picklist using itemDisable

4.5k Views Asked by At

Does anyone know how to freeze any row in primefaces picklist

Or how to use itemDisabled in

1

There are 1 best solutions below

0
On

To use itemDisabled, simply set the attribute to an EL expression that returns a boolean value. Using PF's demo on the primefaces website, you can disable a row of a player using a condition on the player pojo like so:

 <p:pickList id="pojoPickList" value="#{pickListBean.players}" var="player" itemDisabled="#{player.name eq 'Messi'}"
    itemValue="#{player}" itemLabel="#{player.name}" converter="player"/>

The snippet above will disable the option named "Messi" in the pickList. Optionally, you can as well delegate the evaluation to a backing bean method:

 <p:pickList id="pojoPickList" value="#{pickListBean.players}" var="player" itemDisabled="#{backingBean.isDisabled(player)}"
    itemValue="#{player}" itemLabel="#{player.name}" converter="player"/>