mercredi 18 mai 2016

How to Enable/Disable checkbox in dataTable based on the value of column in the row

I need your help in enabling/disabling the checkbox in the dataTable based on the column remarks in the dataTable. If the remarks column is not empty or blank, then the checkbox of the row should be disabled, otherwise it should be enabled if the remarks column is empty or blank.

I need to do it from the backing bean in the method. The dataTable code is:

 <p:dataTable value="#{testController.employeeList}" id="Employee" var="emp" 
rowIndexVar="rowIndex"
    selection="#{testController.selectedEmployees}" rowKey="#{emp.id}" 
rowSelectMode="checkbox">
                        <p:columnGroup type="header">
                        <p:row>
                            <p:column/>
                            <p:column headerText="ID"/>
                            <p:column headerText="Name"/>
                            <p:column headerText="Remarks"/>
                            <p:column headerText="Update"/>
                        </p:row>
                    </p:columnGroup>
                    <p:column selectionMode="multiple"/>
                    <p:column headerText="ID">
                        <h:outputText value="#{emp.id}"/>
                    </p:column>
                    <p:column headerText="Name">
                        <h:outputText value="#{emp.name}" id="name"/>
                    </p:column>
                    <p:column headerText="Remarks">
                        <h:inputText id="inputT1" value="#{emp.remarks}"/>
                    </p:column>
                    <p:column headerText="Update">
                        <p:commandButton id="updateCmd" title="Update"
                                         actionListener="#{testController.updateRecord}">
                        </p:commandButton>
                    </p:column>
</p:dataTable>

In the init method:

public void init() {
if (e.getRemarks.equals("") || e.getRemarks == null)
{
// I need to update the checkbox to be enabled
}
else
{
//I need to update the checkbox to be disabled
}




Aucun commentaire:

Enregistrer un commentaire