How to edit data in cell of datatable primefaces 3.4.2

£可爱£侵袭症+ 提交于 2020-01-07 04:37:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!