[英]How to get selected item from <h:selectOneMenu> in javascript
[英]How to remove a selected item from a selectOneMenu inside a dataTable?
我有一個<p:dataTable/>
,在每一行上都有一個<p:selectOneMenu/>
,它們是從1到列表中存在的項目數的整數列表。 因此,如果我在每個<p:selectOneMenu/>
<p:dataTable />
上有30個項目的列表,將顯示從1到30的選項。但是,我在內部遇到這些<p:selectOneMenu />
我的<p:dataTable />
。 如果在一行中選擇了一項,則必須從其他<p:selectOneMenu/>
項中刪除該項。 例如,如果選擇了項“ 1”,則所有其他項都不能具有數字“ 1”作為要選擇的選項。
那么,有什么辦法可以對我的托管bean /控制器進行處理嗎? 我嘗試使用javascript獲取<p:selectionOneMenu/>
,但未成功,因為我在獲取clientId時遇到問題,而且selectOneMenu使用div來顯示項目。 對這個問題有什么想法嗎?
這是我的xhtml
<p:dataTable id="dataTableSolicitacoes" value="#{pesquisarItemSolicInvestController.listaSolicitacoes}"
selectionMode="single" var="_solicitacao" rowKey="#{_solicitacao.index}" rowIndexVar="index"
selection="#{pesquisarItemSolicInvestController.linhaSelecionada}"
<p:ajax event="rowSelect" listener="#{pesquisarItemSolicInvestController.onRowSelect}" process="@(#dataTableSolicitacoes)" update="@(#dataTableSolicitacoes), @(#panelBotoes)" />
<p:column style="vertical-align: middle; width: 60px !important;">
<f:facet name="header">
<h:outputText value="#{messages.LABEL_PRIORIDADE}" title="#{messages.TITLE_INFORME_ORDEM_PRIO}"/>
</f:facet>
<p:selectOneMenu id="cbPrioridade" value="#{_solicitacao.prioridade}" style="width:60px !important;"
styleClass="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all"
disabled="#{!mf:hasPermission(securityController,'manterItensEnviados,manter')}">
<f:selectItem itemLabel="" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{pesquisarItemSolicInvestController.listaPrioridades}" />
<p:ajax event="change" listener="#{pesquisarItemSolicInvestController.mudarPrioridade(_solicitacao.index)}"
process="@(#dataTableSolicitacoes), @(#panelBotoes)" update="@(#dataTableSolicitacoes), @(#panelBotoes)" />
</p:selectOneMenu>
</p:column>
</p:dataTable>
對於每個在后備bean中選擇一個菜單的菜單,都有不同的選項數組。
然后在f:selectItems中使用它們,如下所示:
<f:selectItems value="#{pesquisarItemSolicInvestController.listaPrioridades[index]}" />
在事件偵聽器方法中,將行索引作為參數,如下所示:
#{pesquisarItemSolicInvestController.mudarPrioridade(_solicitacao.index, index)}
然后從listaPrioridades[index]
之外的所有選項數組中刪除所選項目。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.