使用每一列的不同列表获取数据表中的选定单元格对象

诺里

我正在尝试使用建立时间表<p:datatable>目前,我正在<f:setPropertyActionListener>尝试使用并尝试利用数据表中的rowIndexVar,如您在本周二的以下代码中所见。不幸的是它没有用。问题在于基础模型包含5个列表(每个工作日1个),所以我要在每列上处理不同的列表。

我不知道我是否真的错了。但是到目前为止,还好,现在我只遇到问题,我想从单击的相应单元格中提取数据。到目前为止,这是我的表:

<p:dataTable id="schedule" var="rows" value="#{scheduleBean.emptyRowDefault}"  
             editMode="cell" 
             rowIndexVar="index"                                   
             widgetVar="cellCars" >
    <f:facet name="header">
        #{msg['schedule']}
    </f:facet>
    <p:column headerText="#{msg['hour']}">
        <h:outputText value="#{index+1}" />
    </p:column>

    <p:column headerText="#{msg['time']}">
       <h:outputText value="#{scheduleBean.schedule.times[index]}" />
    </p:column>

    <p:column headerText="#{msg['monday']}">
         <p:commandLink value="#{scheduleBean.schedule.monday[index].name}" onclick="PF('subjectDialog').show();" />  
    </p:column>

    <p:column headerText="#{msg['tuesday']}">
          <p:commandLink update=":form:eventDetails" onclick="PF('subjectDialog').show();" >   
              <f:setPropertyActionListener value="#{scheduleBean.schedule.tuesday.get(index)}" target="#{scheduleBean.subject}" />
              <h:outputText value="#{scheduleBean.schedule.tuesday[index].name}" />
          </p:commandLink>
     </p:column>

     <p:column headerText="#{msg['wednesday']}" >
         <p:commandLink value="#{scheduleBean.schedule.wednesday[index].name}" onclick="PF('subjectDialog').show();" />  
     </p:column>

     <p:column headerText="#{msg['thursday']}">
         <p:commandLink value="#{scheduleBean.schedule.thursday[index].name}" onclick="PF('subjectDialog').show();" />                       
     </p:column>

     <p:column headerText="#{msg['friday']}">
         <p:commandLink value="#{scheduleBean.schedule.friday[index].name}" onclick="PF('subjectDialog').show();" />  
     </p:column>
</p:dataTable>

这个对话框:

<p:dialog widgetVar="subjectDialog" header="Neues Fach anlegen" showEffect="clip" hideEffect="clip" resizable="false">
     <h:panelGrid id="eventDetails" columns="2">
          <p:outputLabel for="name" value="#{msg['subject']}" />
          <p:inputText id="name" value="#{scheduleBean.subject.name}" required="true" />

          <p:outputLabel for="hour" value="#{msg['hour']}" />
              <h:selectOneMenu id="hour" value="#{scheduleBean.subject.hourTime}" style="width:100%">
                  <f:selectItems value="#{scheduleBean.schedule.hours}" var="day" itemLabel="#{hour}" itemValue="#{hour}" />
              </h:selectOneMenu>

          <p:outputLabel for="weekday" value="#{msg['weekday']}" />
              <h:selectOneMenu id="weekday" value="#{scheduleBean.subject.weekday}" style="width:100%">
                  <f:selectItems value="#{scheduleBean.schedule.weekdays}" var="day" itemLabel="#{day}" itemValue="#{day}" />
              </h:selectOneMenu>

           <p:outputLabel for="teacher" value="#{msg['teacher']}" />
                            <p:inputText id="teacher" value="#{scheduleBean.subject.teacher}" required="true" />

           <p:outputLabel for="room" value="#{msg['room']}" />
                            <p:inputText id="room" value="#{scheduleBean.subject.room}" required="true" />

       </h:panelGrid>
       <h:panelGroup style="text-align: center; width: 340px; float: left">
           <p:commandButton id="addButton" styleClass="button button2" value="#{msg['save']}"   action="#{scheduleBean.save}" update="schedule :form:eventDetails" oncomplete="PF('subjectDialog').hide();" />
           <p:commandButton id="delete" styleClass="button button2"   value="#{msg['delete']}"     action="#{scheduleBean.remove(scheduleBean.subject)}" update="schedule msgs" oncomplete="PF('subjectDialog').hide();" />
           <p:commandButton id="cancel"  styleClass="button button2"  value="#{msg['cancel']}"   immediate="true"                                    oncomplete="PF('subjectDialog').hide();" /> 
       </h:panelGroup>
   </p:dialog>
麦琪(Maciej Kowalski)

不确定为什么不为该星期二的行调用您的managedBeans属性,而是关于对话框的刷新,将对话框放置在主窗体之外并inner在对话框本身内添加窗体的一种常见做法是

<p:dialog widgetVar="subjectDialog" header="Neues Fach anlegen" showEffect="clip" hideEffect="clip" resizable="false">
  <h:form id="dialogForm">
     ...
  </h:form>
</p:dialog>

然后,您只需在数据表中执行操作即可update=":dialogForm"

这样做的原因是浏览器可能会将p:dialog的内容重定位到DOM树的其他元素(通常在任何form元素的末尾)。这将导致您所有的按钮和表单元素停止工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

从数据表打印选定单元格的值

数据表:使用 JQuery 更改选定单元格的值

获取选定的单元格元素数据表

使用jquery获取所有单元格值属于html表中的一列

调用同一列中的特定单元格(使用dplyr?)

Pandas - 计算另一列中选定单元格的平均值

数据表:单元格中的下拉列表

使用带有Python的Selenium Webdriver获取HTML表中特定单元格的数据

将项目从一个 2D 列表单元格移动到同一列表中的另一个特定单元格

使用AngularJS的数据表中的单元格按钮

在NSTableView的选定单元格中更改数据

如何在C#中读取表的选定单元格的数据并更新它

从数据表行中获取值并将其作为 R 中的列表放入单元格中

使用一组数据框中的每一列的每个单元格创建最大值的新数据框

获取jQuery创建的表格中某一列中所有单元格的数据

根据 R 中一列中的值获取数据框单元格的值

从行中的选定单元格复制/粘贴单元格数据

要在“选定单元格”中运行并使用基于选定单元格的宏公式

带有条件的表的每一列中的 COUNT 个非空单元格

vba 获取表格中特定单元格的范围(列表对象)

如何在不同表的数据表的单元格中呈现多行?

将 array.tolist() 添加到 Pandas 数据框中的一列后,获取每个单元格中存储一个元素的列表

如何根据R中另一列的条件求和一列的特定单元格?

如何让Excel根据另一个数据表将值粘贴到特定单元格中

数据表,获取隐藏单元格的值

仅使用非NA单元格替换另一列中的单元格

使用Pygsheets查找单元格并更新同一列中的单元格

无法使用 onclick 函数从数据表中获取另一列数据?

快速获取另一个ViewController中选定单元格的数据(以编程方式)