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!