Q:

How to make a primefaces datatable column editable based on a condition

I have a primefaces datatable which has some editable columns. I want to make one of cell in one of the editable columns as non-editable based on some condition, e.g, If that column is color, user should be able to enter different colors. But if the row  contains another column with a particular id('*), user should not be able to update that cell. 
I tried adding disabled based on the condition in the inputText as below.
<p:column  headerText="Color Choice"  >               
                 <p:cellEditor>
                     <f:facet name="output"><h:outputText value="#{row.color}" /></f:facet>
                     <f:facet name="input"><p:inputText id="colorchoice" value="#{row.color}" disabled ="#{row.id.contains('*')}"/></f:facet>     
                    </p:cellEditor>             
                </p:column>

This actually restricts the user from changing that particular cell, but the user still can click and select the cell. 
I want the user not able to click and select it to have a better UI experience,

A:

I think you must use rendered. I give you a sample code. You must change the rendered code.
          <p:column  headerText="Color Choice"  >               
             <p:cellEditor rendered="#{row.color eq 'red'}">
                 <f:facet name="output"><h:outputText value="#{row.color}" /></f:facet>
                 <f:facet name="input"><p:inputText id="colorchoice" value="#{row.color}" /></f:facet>
             </p:cellEditor>
              <h:outputText rendered="#{row.color ne 'red'}" value="#{row.color}"/>
            </p:column>

You can also make in the backing bean a method that can decide if you want to render something or not. And you can render what ever if you want with rendered.   
 <p:dataTable id="cars1" var="car" value="#{somethingBean.cars1}" editable="true" style="margin-bottom:20px">
    <f:facet name="header">
        Row Editing
    </f:facet>

    <p:column headerText="Year" rendered = "#{somethingBean.renderMethod(car)}">
        <p:cellEditor >
            <f:facet name="output"><h:outputText value="#{car.year}" /></f:facet>
            <f:facet name="input"><p:inputText value="#{car.year}" style="width:100%" label="Year"/></f:facet>
        </p:cellEditor>
    </p:column>

    <p:column headerText="Year">
        <<h:outputText value="#{car.year}" />
    </p:column rendered = "#{somethingBean.renderMethod(car)}">

    <p:column style="width:35px">
        <p:rowEditor rendered = "#{somethingBean.renderMethod(car)}"/>
    </p:column>
</p:dataTable>

-----Managebean Method----
 public Boolean renderMethod(Car car) {

 if(car.color.equal("red")){
        return true;
    }else{
       return false;
    }
 }

