PrimeFaces 扩展 - pe:sheet 未在更改时更新
我不确定如何在不直接编辑单元格的情况下更新 pe:sheet。目前,当我对单元格进行修改时,底层列表中的数据不会被修改,而当我修改底层列表时,前端也不会更新。我应该如何同步这两个用户?
这是 HTML:
<script type="text/javascript">
function sheetExtender() {
this.cfg.enterMoves = {row: 1, col: 0};
}
</script>
<pe:sheet id="mySheet" widgetVar="mySheet" value="#{myView.objList}"
var="obj" rowKey="#{obj.listIndex}" style="color: #757575;" height="400"
showRowHeaders="true" sortOrder="ascending" width="1000" extender="sheetExtender">
<p:ajax event="change" listener="#{myView.onChange}" update="mySheet"/>
<pe:sheetcolumn headerText="X" value="#{obj.x}" colType="checkbox"/>
<pe:sheetcolumn headerText="Y" value="#{obj.y}" />
<pe:sheetcolumn headerText="Z" value="#{obj.z}" />
</pe:sheet>
和更改处理程序:
public void onChange(SheetEvent event) {
Sheet sheet = event.getSheet();
List<SheetUpdate> updates = sheet.getUpdates();
SheetUpdate sheetUpdate = updates.get(0);
Integer rowId = (Integer) sheetUpdate.getRowKey();
Integer colId = (Integer) sheetUpdate.getColIndex();
String oldValue = (String) sheetUpdate.getOldValue();
String newValue = (String) sheetUpdate.getNewValue();
sheet.appendUpdateEvent(rowId, colId + 1, "DUMMY", null, "DUMMY");
sheet.commitUpdates();
}
我找不到任何特定的方法或小部件功能来保持这两者同步。如果您知道执行此操作的正确方法,请告诉我您是如何找到它的。
谢谢!
I am unsure how one updates a pe:sheet without directly editing a cell. Currently, when I make a modification to a cell, the data in the underlying list is not modified, and when I modify the underlying list, the front end is not updated. How should I user sync these two?
Here is the HTML:
<script type="text/javascript">
function sheetExtender() {
this.cfg.enterMoves = {row: 1, col: 0};
}
</script>
<pe:sheet id="mySheet" widgetVar="mySheet" value="#{myView.objList}"
var="obj" rowKey="#{obj.listIndex}" style="color: #757575;" height="400"
showRowHeaders="true" sortOrder="ascending" width="1000" extender="sheetExtender">
<p:ajax event="change" listener="#{myView.onChange}" update="mySheet"/>
<pe:sheetcolumn headerText="X" value="#{obj.x}" colType="checkbox"/>
<pe:sheetcolumn headerText="Y" value="#{obj.y}" />
<pe:sheetcolumn headerText="Z" value="#{obj.z}" />
</pe:sheet>
And the change handler:
public void onChange(SheetEvent event) {
Sheet sheet = event.getSheet();
List<SheetUpdate> updates = sheet.getUpdates();
SheetUpdate sheetUpdate = updates.get(0);
Integer rowId = (Integer) sheetUpdate.getRowKey();
Integer colId = (Integer) sheetUpdate.getColIndex();
String oldValue = (String) sheetUpdate.getOldValue();
String newValue = (String) sheetUpdate.getNewValue();
sheet.appendUpdateEvent(rowId, colId + 1, "DUMMY", null, "DUMMY");
sheet.commitUpdates();
}
I cannot find any particular method or widget function to keep these two in sync. If you know the correct method to do this, please let me know how you found it.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Gumpf 你一切都正确......你只能从 UI 前端编辑单元格。
更改支持 bean 中的值不会反映在工作表中,除非您
update="sheet"
再次重绘整个工作表。该工作表的全部目的是不像可编辑数据表,如果您有一个 10x10 可编辑数据表,它每次都会在表单提交上提交 1000 个值。如果您有 20x20 那么它就不起作用,因为大多数服务器会在 1000 个表单提交项时阻止您。因此,工作表的设计目的只是一次更新一个或多个单元格,以更新您的支持 bean,而无需重新绘制工作表。您想要通过更新支持 bean 值并将其反映在工作表中来实现的唯一方法是
update="sheet"
在更新支持后强制整个工作表重新渲染bean 值可能不是您想要的。或者它可能是......@Gumpf you have everything correct...you can only edit cells from the UI front end.
Changing the values in the backing bean will NOT reflect in the Sheet unless you
update="sheet"
to redraw the entire sheet again. The whole purpose of the Sheet is to not act like an Editable datatable where if you had a 10x10 editable DataTable it would submit 1000 values on Form Submit every time. If you had a 20x20 then it wouldn't work as Most servers stop you at 1000 Form Submit items.So the Sheet is designed just to update a cell or cells at a time to update your backing bean WITHOUT having to redraw the sheet. What you want to do by updating your backing bean values and have it reflect in the Sheet the only way that will work is
update="sheet"
to force the whole Sheet to re-render after updating your backing bean values which might not be what you want. Or it might be....