簡體   English   中英

用戶選擇一行后如何顯示對話框 <p:datatable> ?

[英]How to show a dialog after the user select a row of a <p:datatable>?

我有此數據表:

<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single" selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
       <p:column headerText="Equipo">
          <h:outputText value="#{ref.equipo}" />
       </p:column>
       <p:column headerText="Marca">
          <h:outputText value="#{ref.marca}" />
       </p:column>
       //More colums here...
</p:dataTable>

我想在用戶選擇一行后顯示此對話框:

<p:dialog id="myDialog" widgetVar="refaccionDialog" header="Detalle Refaccion" resizable="false" width="300" showEffect="explode" hideEffect="explode">
     <h:panelGrid id="display" columns="2" cellpadding="4">
          <h:outputText value="Info:" />
          <h:outputText value="#{consultasBean.refaccionSeleccionada.equipo}" />
     </h:panelGrid>
     //More things here...
 </p:dialog>

這是我的bean(viewscoped)的一部分:

private List<RefaccionBean> listaRefacciones = null;
private RefaccionBean refaccionSeleccionada = null;
// setters and getters...

listaRefacciones已經有信息,所以listaRefacciones擔心它如何得到。

我知道我必須使用p:ajax,但不知道如何使用。

我正在檢查這一點 (示例1是我想要的),但是信息太舊了,現在無法正常工作。

請幫我。

只需在表中包含ap:ajax

<p:ajax event="rowSelect" oncomplete="PF('refaccionDialog').show()" update=":dialogId" />

希望這可以幫助。

datatable的rowKey屬性被錯誤地寫入。 它應該如下所示

  rowKey="#{ref.idRefaccion}"

數據表代碼應如下

   <h:form id="form">
   <p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single"
      selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
   <p:column headerText="Equipo">
      <h:outputText value="#{ref.equipo}" />
   </p:column>
   <p:column headerText="Marca">
      <h:outputText value="#{ref.marca}" />
   </p:column>
   //More colums here...
   </p:dataTable>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM