问题
My project use primefaces ver 3.4.2. I don't see that version supporting cell editing in datatable as showcased here. 3.4.2 has row editing that has many action to edit data in datatable. I cannot upgrade the primefaces library version. How can I achieve cell editing in 3.4.2?
回答1:
try this : editable="true" and editMode="cell" which will allow us to edit cell.. (this is supported in 3.4.2) and columns must be written as below ..
<p:dataTable id="cars" var="car" value="#{tableBean.carsSmall}" editable="true"
editMode="cell" widgetVar="carsTable">
<p:ajax event="cellEdit" listener="#{tableBean.onCellEdit}" update=":form:messages" />
<p:column headerText="Model" style="width:25%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.model}" />
</f:facet>
<f:facet name="input">
<p:inputText id="modelInput" value="#{car.model}" style="width:96%"/>
</f:facet>
</p:cellEditor>
</p:column>
</p:datatable>
回答2:
<p:column headerText="#{tdBundle['Tdkt_VoteEmp.agreeNum.label']}">
<!--<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{unit.agreeNum1}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{unit.agreeNum1}" />
</f:facet>
</p:cellEditor>-->
<p:inplace id="basic">
<p:inputText value="#{unit.agreeNum1}"/>
</p:inplace>
</p:column>
That is my code. When agreeNum1 has no data. I cannot click in that cell to input data.
来源:https://stackoverflow.com/questions/20739076/how-to-edit-data-in-cell-of-datatable-primefaces-3-4-2