PROBLEM: When edit cell is enabled and I edit the cell and leave it (see below code for exact setup of grid), the edits are there and save has not been initiated yet. Then I edit that cell again to undo using the escape key. The grid shows the edit being undone, but the edit values still exist. My code shows summary values of the column and must determine to whether to use the edit value or the original value of that cell. The only way I know that it has an edit value is using grid.getEditValues for the record.
SOLUTION: Shouldn't the edit value for that record's cell not have a edit value?
The documentation indicates that EscapeKeyEditAction.CANCEL "cancels the current edit and discards edit values".
1. SNAPSHOT_v10.1d_2015-07-30/Enterprise Deployment 2015-07-30
2. Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:26.0) Gecko/20100101 Firefox/26.0
Here is the setup of my grid:
When I hit the escape key, then the editor exits and I recompute the summary:
Here is the summary function that does get call when I move from the cell after editing or hitting the escape key when I'm editing the cell.
SOLUTION: Shouldn't the edit value for that record's cell not have a edit value?
The documentation indicates that EscapeKeyEditAction.CANCEL "cancels the current edit and discards edit values".
1. SNAPSHOT_v10.1d_2015-07-30/Enterprise Deployment 2015-07-30
2. Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:26.0) Gecko/20100101 Firefox/26.0
Here is the setup of my grid:
Code:
grid.setEscapeKeyEditAction(EscapeKeyEditAction.CANCEL); grid.setCanEdit(true); grid.setModalEditing(true); grid.setEditEvent(ListGridEditEvent.DOUBLECLICK); grid.setListEndEditAction(RowEndEditAction.NEXT); grid.setEditByCell(true); grid.setCanSelectCells(true); grid.setAutoSaveEdits(false); grid.setShowAllRecords(true); grid.setCanReorderRecords(true); grid.setIncludeInSummaryProperty("_include");
Code:
grid.addEditorExitHandler(new EditorExitHandler() { @Override public void onEditorExit(EditorExitEvent event) { if(event.getRowNum() > 1) editGrid.recalculateSummaries(); } });
Code:
SummaryFunction sf = new SummaryFunction() { @Override public Object getSummaryValue(Record[] records, ListGridField field) { Double total = 0.0; String sval = null; Object oval = null; String fname = field.getName(); int index=0; for(ListGridRecord record: grid.getRecords()) { if(2 > (index = grid.getRecordIndex(record))) continue; @SuppressWarnings("unchecked") Map<String,Object> ed = grid.getEditValues(record); if(ed.containsKey(fname)) { oval = ed.get(fname); SC.logWarn(fname + " Edit value = " + oval.toString()); total += Double.valueOf((String) oval); } else if(null != (sval = record.getAttribute(fname))) { total += Double.valueOf(sval); SC.logWarn(fname + "(" + index + ") Stat value = " + sval.toString()); } } return (Object) total; } };
Comment