如何在accodionPanel中显示所选行的数据?

发布于 2024-11-30 10:54:46 字数 2807 浏览 0 评论 0原文

我按照这个数据表选择的例子,一切正常: DataTable - Row Selection

我尝试更改此示例,而不是对话框和面板网格,显示所选行的数据,我想要 AccordionPanel 带有一个选项卡和该选项卡中的面板网格。在开始时,accordionPanel activeIndex =“-1”。

这是我的代码:

<h:form id="formEditUser">
     <p:panel header="User Editing">
         <p:dataTable value="#{ikBean.userList}" var="user" id="usersTable" paginator="true" rows="5" paginatorPosition="bottom"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                             selection="#{ikBean.selectedUser}" selectionMode="single">
              <f:facet name="header">
                        Users
              </f:facet>

              <p:column filterBy="#{user.name}" headerText="Name" filterMatchMode="contains">
                  <h:outputText value="#{user.name}"/>
              </p:column>

              <p:column filterBy="#{user.surname}" headerText="Surname" filterMatchMode="contains">
                  <h:outputText value="#{user.surname}"/>
              </p:column>

              <p:column filterBy="#{user.jmbg}" headerText="JMBG" filterMatchMode="startsWith">
                  <h:outputText value="#{user.jmbg}"/>
              </p:column>

              <p:column filterBy="#{user.userName}" headerText="User Name" filterMatchMode="startsWith" style="width: 120px;">
                  <h:outputText value="#{user.userName}"/>
              </p:column>

              <f:facet name="footer">
                   <p:commandButton value="Edit" image="ui-icon ui-icon-refresh"
                                         update=":formEditUser:display" oncomplete="accordionEdit.select(0)"/>

                   <p:commandButton value="Clear" image="ui-icon ui-icon-close" process=":@this" update="usersTable"/>
              </f:facet>

          </p:dataTable>

          <p:accordionPanel activeIndex="-1" widgetVar="accordionEdit">
                    <p:tab title="User Editing">
                        <h:panelGrid columns="2" cellpadding="10" id="display">
                            <h:outputLabel for="name" value="Name: "/>
                            <p:inputText id="name" required="true" label="name" size="25" value="#{ikBean.selectedUser.name}"/>
                        </h:panelGrid>
                    </p:tab>
          </p:accordionPanel>
      </p:panel>
 </h:form>

我的结果是:折叠的选项卡(这就是我想要的,但是)其中没有任何数据。当然,我忘了提到在面板网格中我有一些输入文本字段......一切都像 primefaces 示例一样。有什么想法吗?

I followed this example of datatable selection, and everything works fine:
DataTable - Row Selection

I tried to change this example and instead of dialog and panel grid, that shows up with data of selected row, I want accordionPanel with one tab and panel grid in that tab. At the beginning accordionPanel activeIndex="-1".

Here is my code:

<h:form id="formEditUser">
     <p:panel header="User Editing">
         <p:dataTable value="#{ikBean.userList}" var="user" id="usersTable" paginator="true" rows="5" paginatorPosition="bottom"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                             selection="#{ikBean.selectedUser}" selectionMode="single">
              <f:facet name="header">
                        Users
              </f:facet>

              <p:column filterBy="#{user.name}" headerText="Name" filterMatchMode="contains">
                  <h:outputText value="#{user.name}"/>
              </p:column>

              <p:column filterBy="#{user.surname}" headerText="Surname" filterMatchMode="contains">
                  <h:outputText value="#{user.surname}"/>
              </p:column>

              <p:column filterBy="#{user.jmbg}" headerText="JMBG" filterMatchMode="startsWith">
                  <h:outputText value="#{user.jmbg}"/>
              </p:column>

              <p:column filterBy="#{user.userName}" headerText="User Name" filterMatchMode="startsWith" style="width: 120px;">
                  <h:outputText value="#{user.userName}"/>
              </p:column>

              <f:facet name="footer">
                   <p:commandButton value="Edit" image="ui-icon ui-icon-refresh"
                                         update=":formEditUser:display" oncomplete="accordionEdit.select(0)"/>

                   <p:commandButton value="Clear" image="ui-icon ui-icon-close" process=":@this" update="usersTable"/>
              </f:facet>

          </p:dataTable>

          <p:accordionPanel activeIndex="-1" widgetVar="accordionEdit">
                    <p:tab title="User Editing">
                        <h:panelGrid columns="2" cellpadding="10" id="display">
                            <h:outputLabel for="name" value="Name: "/>
                            <p:inputText id="name" required="true" label="name" size="25" value="#{ikBean.selectedUser.name}"/>
                        </h:panelGrid>
                    </p:tab>
          </p:accordionPanel>
      </p:panel>
 </h:form>

My result is: collapsed tab (that is what i wanted, but) without any data in it. Of course, I forgot to mention that in panel grid I have some input text fields...everything like the primefaces example. Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗼ふ静 2024-12-07 10:54:46

尝试将

prependId 添加到您的并尝试这两个值 - True 或 False 。有一段时间我忘记了它是假的还是真的,让我知道它是否有效。

Try this out

add prependId to your and try both values - True or False . It been a while I forgot is it false or true and let me know is it working or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文