我有一個 PrimeFaces 按鈕,它應該通過 Java 處理數(shù)據(jù)并將其顯示在數(shù)據(jù)表中。這是代碼: <p:dataTable rowIndexVar="rowIndex" var="report" id="TableResult" style="height:685px;width: 97vw;" value="#{reportResultController.resultRows}" resizableColumns="true" scrollable="true" scrollHeight="95%" scrollRows="30" liveScroll="true" lazy="false"/>和按鈕呈現(xiàn)表的數(shù)據(jù)(): <p:commandButton value="Report " action="#{ReportController.produceReport}" id="produce_report" update="TableResult" process="TableResult"/>這是Java部分 public void produceReport() { resultRows = reportResultUtils.runReport(rph, rowsLimit); //Returning List of rows} public List<Object[]> getResultRows() { return resultRows;}數(shù)據(jù)處理工作正常。問題是,在我為相同的數(shù)據(jù)按兩次按鈕的情況下,我第一次看到結(jié)果,下次我看到它加倍而不是一次。第一次身份證名稱1 大衛(wèi)2 喬第二次身份證名稱1 大衛(wèi)2 喬1 大衛(wèi)2 喬第三次和第四次保持它只像第二次一樣翻倍。如果我更改參數(shù)以獲得不同的表,則它會清除表而不是混淆數(shù)據(jù)。在 resultRows 變量中設置新數(shù)據(jù)之前,我該怎么做才能只顯示一次或刪除表中的數(shù)據(jù)?
1 回答

揚帆大魚
TA貢獻1799條經(jīng)驗 獲得超9個贊
行
原來是PrimeFace的bug。
確實正如@Kukeltje 提到的,問題出在liveScroll="true". 當我刪除它時,它起作用了。
因此,解決方法是向RowsDataTable添加與以下大小相同的屬性scrollRows:
<p:dataTable rowIndexVar="rowIndex" var="report"
id="TableResult"
style="height:685px;width: 97vw;"
value="#{reportResultController.resultRows}"
resizableColumns="true"
scrollable="true"
scrollHeight="95%"
scrollRows="30"
rows="30" <!-- This is the solution-->
liveScroll="true"
lazy="false"/>
添加回答
舉報
0/150
提交
取消