I'm using Primefaces 5.3, and I'm filling a datatable with some records from the database if the length of records is lower than 10 I complete it with empty records so the datatable always diplays 10 rows.
My datatable looks like this :
<p:dataTable id="dataTable"
editable="true" editMode="cell"
value="#{beanPlanningl.getListPlanningSalle(entry, 1)}"
var="planning"
selectionMode="single"
selection="#{beanPlanning.selectedPlanning}"
rowKey="#{planning.id}"
sortBy="#{planning.heureDebut}"
>
So what I want is to disable selection on rows that has the empty records.
How can I do that ?
PS : planning.id
equals 0 in empty records.
Edit :
I forgot to mention that I already used rendered
as following :
<p:column >
<p:cellEditor rendered="#{planning.id != 0}">
<f:facet name="output"> <h:outputText value="#{planning.heureDebut}" /></f:facet>
<f:facet name="input">
<p:inputMask mask="99:99" value="#{planning.heureDebut}"
required="true" maxlength="4"
requiredMessage="Heure de début : vous devez indiquer une valeur."
validatorMessage="Heure de début non valide.">
<f:validateRegex pattern="([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]"/>
</p:inputMask>
</f:facet>
</p:cellEditor>
</p:column>
But this only prevents from editing cells, but they can be always selected.
Edit 2 :
I tried to use disabledSelection
now I can't select rows but cells can always be selected, before I used disabledSelection
:
as you can see I can select rows and on hovering they get colored.
and then when I used disabledSelection
:
Now hovering doesnt work for empty rows and selection on rows as well, but the cells can always be selected, so no I only need to prevent that from hapenning.
I noticed that when the cell is selected two css classes are added : ui-state-highlight ui-cell-editing
.