2015-07-28 75 views
2
<ui:composition template="/template.xhtml"> 
    <ui:define name="title"> 
     <h:outputText value="#{bundle.ListDriverTitle}"></h:outputText> 
    </ui:define> 
    <ui:define name="body"> 
     <h:form id="driverForm"> 
      <h:panelGrid id="messagePanel" > 
       <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/> 
      </h:panelGrid> 
      <h:panelGrid > 
       <p:dataTable value="#{driverController.items}" lazy="true" selectionMode="single" paginator="true" rows="10" paginatorPosition="bottom" var="item" id="itemTable" rowKey="#{item.id}" styleClass="ui-datatable-hor-scroll"> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_id}"/> 
         </f:facet> 
         <h:outputText value="#{item.id}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_surname}"/> 
         </f:facet> 
         <h:outputText value="#{item.surname}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_names}"/> 
         </f:facet> 
         <h:outputText value="#{item.names}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_idNumber}"/> 
         </f:facet> 
         <h:outputText value="#{item.idNumber}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_driverCode}"/> 
         </f:facet> 
         <h:outputText value="#{item.driverCode}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_active}"/> 
         </f:facet> 
         <h:outputText value="#{item.active}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_type}"/> 
         </f:facet> 
         <h:outputText value="#{item.type}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_cellNumber}"/> 
         </f:facet> 
         <h:outputText value="#{item.cellNumber}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_createdDate}"/> 
         </f:facet> 
         <h:outputText value="#{item.createdDate}"> 
          <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" /> 
         </h:outputText> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="#{bundle.ListDriverTitle_whs}"/> 
         </f:facet> 
         <h:outputText value="#{item.whs.name}"/> 
        </p:column> 
        <p:column> 
         <f:facet name="header"> 
          <h:outputText value="&nbsp;"/> 
         </f:facet> 
         <p:commandButton action="#{driverController.prepareView}" value="#{bundle.ListDriverViewLink}" ajax="false" immediate="false"> 
          <f:setPropertyActionListener target="#{driverController.selectedDriver}" value="#{item}"/> 
         </p:commandButton> 
         <h:outputText value=" "/> 
         <p:commandButton action="#{driverController.prepareEdit}" value="#{bundle.ListDriverEditLink}" ajax="false" immediate="false"> 
          <f:setPropertyActionListener target="#{driverController.selectedDriver}" value="#{item}" /> 
         </p:commandButton> 
         <h:outputText value=" "/> 
         <p:commandButton action="#{driverController.destroy}" value="Delete" ajax="false" immediate="false"> 
          <f:setPropertyActionListener target="#{driverController.selectedDriver}" value="#{item}"/> 
         </p:commandButton> 
        </p:column> 
       </p:dataTable> 
      </h:panelGrid> 
      <br /> 
      <p:commandButton action="#{driverController.prepareCreate}" value="#{bundle.ListDriverCreateLink}" ajax="false"/> 
      <p:menuButton value="Download Documents"> 
       <p:menuitem immediate="true" process="@none" ajax="false"> 
        <h:commandLink target="_blank"> 
         <img src="#{resource['images/excel-icon.png']}" style="border: none; width: 15px; height: 15px;"/> 
         <p:dataExporter type="xls" target="itemTable" fileName="DriversList" pageOnly="true"/> 
         <span>Current page</span> 
        </h:commandLink> 
       </p:menuitem> 
       <p:menuitem immediate="true" process="@none" ajax="false"> 
        <h:commandLink target="_blank"> 
         <img src="#{resource['images/excel-icon.png']}" style="border: none; width: 15px; height: 15px;"/> 
         <p:dataExporter type="xls" target="itemTable"fileName="DriversList" p/> 
         <span>All pages</span> 
        </h:commandLink> 
       </p:menuitem> 
      </p:menuButton> 
     </h:form> 
    </ui:define> 
</ui:composition> 

導出到Excel文件中PrimeFaces

當我下載一個Excel文件時排除在數據表按鈕,從表中的按鈕也被下載。我能做些什麼來排除它們。

如果您需要更多的解釋,請隨時問我。我需要最好的解決方案。謝謝

回答

1

您可以排除列,不應使用導出:

<p:column exportable="false"> 
+0

工程。謝謝 – Mimshach

+0

很高興聽到:)請將此標記爲已接受的答案 –

+0

我添加了一個過濾器,但它不起作用: Mimshach