gpt4 book ai didi

java - 如何更新 primefaces 数据表中的特定单元格

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:13:26 24 4
gpt4 key购买 nike

我正在创建一个充满输入字段的动态数据表。有时,当用户在某些输入中插入值时,应该更新特定的单元格,并且只更新该单元格。我认为这可能很简单,但并没有让它发挥作用。我要更新的单元格是“valor total”,当其他两个单元格的值发生变化时,应该更新这个单元格:

cell to update

已编辑

js chrome

我尝试了带有完整 ID 的 f:ajax 并得到“带有 id:lancamentoNF:popupLancamentoNF:tabelaItensNF:0:valorTotalItem 的组件未找到”。更改为 p:ajax 并且没有发生错误,但它不会更新!

<h:panelGroup id="painelItensNF" layout="block" styleClass="hrgi-div-form aba-lancamento-nf clearfix" style="overflow:auto;">
<h:panelGroup layout="block" style="width: 1700px;">
<p:dataTable id="tabelaItensNF" value="#{modeloTabelaDinamicaItemNF.itens}" var="itemEmbrulhado" styleClass="tabelaDinamica" height="174" style="width: 100%;" rowIndexVar="indice">
... (some columns)
<p:column style="width: 5%"
headerText="quantidade">
<hrgi:spinner id="quantidadeItem"
value="#{itemEmbrulhado.item.produto.detalheTributavel.quantidade}"
dinheiro="false"
fator="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?0.01:1}"
local="pt-BR" min="0.00" width="70">
<p:ajax event="change"
update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem"
listener="#{controladorPopupLancamentoNF.calcularValorTotalItem(itemEmbrulhado)}" global="false" />
<f:convertNumber
maxFractionDigits="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?2:0}"
minFractionDigits="#{itemEmbrulhado.item.produto.detalheTributavel.unidadeFracionada?2:0}"
locale="pt-BR"
for="quantidadeItem"/>
</hrgi:spinner>
</p:column>
<p:column style="width: 5%"
headerText="valor unitario">
<hrgi:spinner id="valorUnitarioItem"
value="#{itemEmbrulhado.item.produto.detalheTributavel.valorUnitario}"
dinheiro="true" fator="0.01" local="pt-BR" min="0.00" width="70">
<p:ajax event="change"
update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem"
listener="#{controladorPopupLancamentoNF.calcularValorTotalItem(itemEmbrulhado)}" global="false"/>
<f:convertNumber type="currency" currencyCode="BRL" currencySymbol="R$ "
maxFractionDigits="10" minFractionDigits="2" locale="#{cc.attrs.local}"
for="valorUnitarioItem"/>
</hrgi:spinner>
</p:column>
<p:column style="width: 3%"
headerText="valor total">
<h:outputText id="valorTotalItem" value="#{itemEmbrulhado.item.produto.valorTotal}">
<f:convertNumber type="currency" currencyCode="BRL" currencySymbol="R$ "
maxFractionDigits="2" minFractionDigits="2" locale="pt-BR"
for="valorUnitarioItem"/>
</h:outputText>
</p:column>
... (more columns)
</p:dataTable>
</h:panelGroup>
</h:panelGroup>

当我用完整的 id 更新面板组“painelItensNF”时,它起作用了,但是焦点丢失了,用户应该找到他正在工作的输入以继续...

最佳答案

只需使用 update="valorTotalItem"。它已经相对于当前行。

所以,替换

<p:ajax ... update="lancamentoNF:popupLancamentoNF:tabelaItensNF:#{indice}:valorTotalItem" />

通过

<p:ajax ... update="valorTotalItem" />

关于java - 如何更新 primefaces 数据表中的特定单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10636324/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com