簡體   English   中英

按下Tab鍵時會觸發CellEdit事件

[英]CellEdit event fires when press tab button

我的問題是,當我在編輯datatable時按下tab鍵時,datatable的單元格被關閉,並且CellEdit事件越來越多地觸發。 它迫使我在屏幕上單擊左鍵單擊任何軟件,以防止觸發單元格編輯事件。

關於單元格方法,我做了一些計算以顯示在頁腳中。 因此,它失去了光標焦點。

我正在使用jsf 2.2和primefaces 6.1。

我的目標是編輯數量,進行計算並更新頁腳行以及總計和凈列,然后按Tab光標出現在價格單元中

我試圖只更新p:columnGroup頁腳,但失敗了。

我嘗試使用a:autofocus但也失敗了。

 <p:remoteCommand name="onCellEdit" update="invInventoryTable" />
 <p:dataTable  var="invInventoryTable"
   widgetVar="invInventoryTable"
   rowIndexVar="index" 
   rowKey="#{invInventoryTable}"
   selectionMode="single"
   selection="#{invPurchaseOrderFormMB.invPurchaseOrderDetailEntitySelection}"
   dir="rtl" 
   emptyMessage="#{userData.userDDs['EMPTY_TABLE']}"
   editable="true"
   editMode="cell"
   value="#{invPurchaseOrderFormMB.invPurchaseOrderEntity.invPurchaseOrderDetailEntityList}"
   id="invInventoryTable">
     <p:ajax event="cellEdit" listener="#{invPurchaseOrderFormMB.onCellEdit}" oncomplete="onCellEdit()"/>

     <p:column style="width:7vh;font-size:1.6vh;text-align: right" a:autofocus="#{invPurchaseOrderFormMB.focus}" id="Quantity" headerText="QUANTITY">
         <p:cellEditor>
             <f:facet name="output">
                 <h:outputText value="#{invInventoryTable.quantity}"  />
             </f:facet>
             <f:facet name="input">
                 <p:inputText id="QuantityT" a:autofocus="#{invPurchaseOrderFormMB.focus}" value="#{invInventoryTable.quantity}"  style="width:90%"/>
             </f:facet>
         </p:cellEditor>                        
     </p:column>

     <p:column style="width:7vh;font-size:1.6vh;text-align: right" id="Price" headerText="PRICE">
         <p:cellEditor>
             <f:facet name="output">
                 <h:outputText  value="#{invInventoryTable.price}"  />
             </f:facet>
             <f:facet name="input">
                 <p:inputText id="PriceT" value="#{invInventoryTable.price}"  style="width:100%"/>
             </f:facet>
         </p:cellEditor>                        
     </p:column>

     <p:column style="width:7vh;font-size:1.6vh;text-align: right" id="Discount" headerText="DISCOUNT">
         <p:cellEditor>
             <f:facet name="output">
                 <h:outputText value="#{invInventoryTable.discountRate}"/>
             </f:facet>
             <f:facet name="input">
                 <p:inputText id="DiscountT" value="#{invInventoryTable.discountRate}"  style="width:100%">
                 </p:inputText>
             </f:facet>
         </p:cellEditor>                        
     </p:column>

     <p:column style="width:7vh;font-size:1.6vh;text-align: right"  id="total" headerText="TOTAL">
         <h:outputLabel id="totalVal" value="#{invInventoryTable.total}"  />
     </p:column>

     <p:column style="width:7vh;font-size:1.6vh;text-align: right" id="NET" headerText="NET">
         <h:outputLabel id="netVal" value="#{invInventoryTable.net}"  />
     </p:column>

     <p:columnGroup type="footer">
         <p:row>
             <p:column colspan="4" style="text-align:right" footerText="TOTAL  :" />
             <p:column id="qtyId" footerText="#{invPurchaseOrderFormMB.totalQuatity}" />
             <p:column/>
             <p:column/>
             <p:column id="totId" footerText="$#{invPurchaseOrderFormMB.total}" />
             <p:column id="totNetId" footerText="$#{invPurchaseOrderFormMB.totalNet}" />
             <p:column/>
             <p:column/>
             <p:column/>
             <p:column/>
             <p:column/>
         </p:row>
     </p:columnGroup>

 </p:dataTable>

我在項目中開發了類似的東西。 我的解決方案是禁用datatable單元格編輯,並根據需要僅將ajax用於數量單元格:

<p:dataTable  var="invInventoryTable"
                              widgetVar="invInventoryTable"
                              rowIndexVar="index" 
                              rowKey="#{invInventoryTable}"
                              selectionMode="single"
                              selection="#{invPurchaseOrderFormMB.invPurchaseOrderDetailEntitySelection}"
                              dir="rtl" 
                              emptyMessage="#{userData.userDDs['EMPTY_TABLE']}"
                              editable="true"
                              editMode="cell"
                              value="#{invPurchaseOrderFormMB.invPurchaseOrderEntity.invPurchaseOrderDetailEntityList}"
                              id="invInventoryTable">


                    <p:ajax event="cellEdit" onstart="return false;" process="@this"/>



                    <p:column style="width:7vh;font-size:1.6vh;text-align: right" a:autofocus="#{invPurchaseOrderFormMB.focus}" id="Quantity" headerText="QUANTITY">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{invInventoryTable.quantity}"  />
                            </f:facet>

                            <f:facet name="input">
                                <p:inputText id="QuantityT" a:autofocus="#{invPurchaseOrderFormMB.focus}" 
              onkeydown="if(event.keyCode != 9 &amp;&amp; event.keyCode != 13){onkeydown();
           value="#{invInventoryTable.quantity}"  style="width:90%"

                             <p:ajax event="keydown" listener="#{invPurchaseOrderFormMB.onCellEdit}" update=""/>           
                              </p:inputText>
                            </f:facet>
                        </p:cellEditor>                        
                    </p:column>

我希望它會有所幫助:)

暫無
暫無

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

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