如何使用Primefaces 3.4.2通过单击或编辑Datatable中的单个列来添加单元格编辑

时间:2016-02-08 11:48:37

标签: jsf primefaces datatable

我正在使用Primefaces 3.4.2,由于某些限制,我无法将其更新到最新版本。我必须在下面代码的数据表中为“Contact”列添加一个编辑选项,以便用户可以编辑并更新它。

我已经尝试过使用Primefaces inplace和行编辑(仅适用于单个列),但单击“保存”或“取消”按钮时提交需要很长时间。

任何人都可以帮我吗?

非常感谢您的帮助。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui">

    <p:dialog id="viewSitesHistoricAlarm" header="Alarm Information" widgetVar="viewSiteHistoricAlmDialog" modal="false" minWidth="930" 
        minHeight="600" fixedCenter="false" appendToBody="true" effect="FADE" effectDuration="0.5" close="true" closeListener="#{historicActivity.dlgClose}">

        <h:form id="viewsiteHistoricAlmFrm">
          <h:panelGrid columns="1" style="margin:5px;" id="printid">
                 <p:dataTable id="alarmResolution"  var="alm" value="#{historicActivity.alarmResolution}" 
                            style="border-right-width: 2px !important;overflow: -moz-scrollbars-vertical;overflow-x: auto;overflow-y: auto; width:895px;max-height:500px !important;" paginatorPosition="top" paginatorTemplate="{PreviousPageLink} {CurrentPageReport}
                            {NextPageLink}" editable="true" rows="100" paginatorAlwaysVisible="false">
                            <p:ajax event="rowEdit" listener="#{historicActivity.updateContactName}" />
                                <p:column style="width:155px">
                                    <f:facet name="header">
                                        <h:outputText value="Action Time"/>
                                    </f:facet>
                                    <h:outputText value="#{alm.timeActioned}"/>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        <h:outputText value="User"/>
                                    </f:facet>
                                    <h:outputText value="#{alm.user}"/>
                                </p:column>
                                <p:column style="width:140px" >
                                    <f:facet name="header">
                                        <h:outputText value="Action"/>
                                    </f:facet>
                                    <h:outputText value="#{alm.action}"/>
                                </p:column>


  <p:column style="width:140px" >
                                <f:facet name="header">
                                    <h:outputText value="Contact"/>
                                </f:facet>
                                <h:outputText value="#{alm.alm.contactName}"/>
                            </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Comments"/>
                                    </f:facet>
                                    <h:outputText value="#{alm.comments}"/>
                                </p:column>
                                 <p:column headerText="Modify">
                    <p:rowEditor />
                 </p:column>
                            </p:dataTable>
                            <p:toolbar>
                                <p:toolbarGroup align="left">
                                <p:commandButton value="CSV" ajax="false" style="color:#A8A6A8!important;">
                                        <p:dataExporter type="csv" target="alarmResolution" fileName="historicalarminfo" preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}"/>
                                    </p:commandButton>
                                    <p:commandButton value="PDF"  style="color:#A8A6A8!important;" update="viewsiteHistoricAlmFrm" onstart= "pdfDownloadDialog.show();"  rendered="#{historicActivity.val==true}">
                                            <f:setPropertyActionListener target="#{pdfExp.columnValues}" value="#{historicActivity.exptrColValsAlmSpecific}"/>  
                                            <f:setPropertyActionListener target="#{pdfExp.tabColumnsWithSize}" value="#{historicActivity.exptrSpecificAlmCol}"/>   
                                            <f:setPropertyActionListener target="#{pdfExp.headerContent}" value="#{historicActivity.exptrHeaderAlmSpecific}"/>               
                                            <f:setPropertyActionListener target="#{pdfExp.logo}" value="#{historicActivity.exptrHeaderLogo}"/> 
                                            <f:setPropertyActionListener target="#{pdfExp.pageTitle}" value="#{historicActivity.exptrPgTitle}"/> 
                                            <f:setPropertyActionListener target="#{pdfExp.fileName}" value="#{historicActivity.exptrFileName}"/>
                                            <f:setPropertyActionListener target="#{pdfExp.redirectTo}" value="HistoricActivityPage?faces-redirect=true"/>            
                                     </p:commandButton>
                                      <p:commandButton value="PDF"  style="color:#A8A6A8!important;"  actionListener
    ="#{historicActivity.checkHistoricSiteAlmsSize}"  update="viewsiteHistoricAlmFrm" rendered
    ="#{historicActivity.val==false}"/>
                                    <p:commandButton value="XLS" ajax="false" style="color:#A8A6A8!important;">
                                        <p:dataExporter type="xls" target="alarmResolution"  preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}" fileName="historicalarminfo"/>
                                    </p:commandButton>
                                </p:toolbarGroup>
                            </p:toolbar>
                         </h:panelGrid>                                
        </h:form>
        </p:dialog>
        </ui:composition>

0 个答案:

没有答案