I have a databound TreeGrid and I can't get the remove operation working correctly.
The effect is that when clicking on the removal icon, the datasource sends a deletion request to the server, the server deletes the record, and the deleted record disappears from the TreeGrid. But then immediately re-appears on the bottom of the Tree, un-parented (if it had a parent). The node has been successfully deleted.
The ResultTree:
The TreeGrid:
Server response:
What am I missing?
SmartClient Version: v10.0p_2014-11-26/Pro Deployment (built 2014-11-26)
Firefox 36.0.1
The effect is that when clicking on the removal icon, the datasource sends a deletion request to the server, the server deletes the record, and the deleted record disappears from the TreeGrid. But then immediately re-appears on the bottom of the Tree, un-parented (if it had a parent). The node has been successfully deleted.
The ResultTree:
Code:
final ResultTree resultTree = new ResultTree();
resultTree.setDefaultNewNodesToRoot(true);
resultTree.setLoadDataOnDemand(true);
resultTree.setModelType(TreeModelType.PARENT);
resultTree.setUpdateCacheFromRequest(true);
resultTree.setDataSource(TransportItemsDS.getInstance(batchBk, incomingBatch));
resultTree.setIdField("businessKey");
resultTree.setParentIdField(parentIdField);
return resultTree;
Code:
final TreeGrid treeGrd = new TreeGrid();
treeGrd.setAlwaysShowOpener(true);
treeGrd.setCanRemoveRecords(true);
treeGrd.setWarnOnRemoval(true);
treeGrd.setCanEdit(true);
treeGrd.setEditEvent(ListGridEditEvent.DOUBLECLICK);
treeGrd.setNodeIcon("icons/16/item.png");
treeGrd.setFolderIcon("icons/16/item.png");
treeGrd.setShowOpenIcons(false);
treeGrd.setShowDropIcons(false);
treeGrd.setClosedIconSuffix("");
treeGrd.setData(parenTree);
treeGrd.setClosedIconSuffix("");
treeGrd.addEditorExitHandler(new EditorExitHandler() {
@Override
public void onEditorExit(EditorExitEvent event) {
if (event.getColNum() == treeGrd.getFieldNum("businessKey")) {
locallySavedBusinessKey = (String) event.getNewValue();
}
}
});
treeGrd.addRemoveRecordClickHandler(new RemoveRecordClickHandler() {
@Override
public void onRemoveRecordClick(RemoveRecordClickEvent event) {
TreeNode treeNode = treeGrd.getRecord(event.getRowNum());
if (treeNode != null) {
locallySavedBusinessKey = treeNode.getAttribute("businessKey");
}
}
});
treeGrd.setContextMenu(buildContextMenu());
TreeGridField idField = new TreeGridField("id", constants.id());
idField.setCanEdit(false);
TreeGridField businessKeyField = new TreeGridField("businessKey", constants.customerDefinedId());
TreeGridField typeField = new TreeGridField("type", constants.type());
TreeGridField categoryField = new TreeGridField("category", constants.category());
TreeGridField incomingContainerField = new TreeGridField("incomingContainer", constants.incomingContainer());
TreeGridField outgoingContainerField = new TreeGridField("outgoingContainer", constants.outgoingContainer());
TreeGridField originField = new TreeGridField("origin", constants.origin());
TreeGridField destinationField = new TreeGridField("destination", constants.destination());
TreeGridField productCodeField = new TreeGridField("productCode", constants.product());
TreeGridField lengthField = new TreeGridField("length", constants.length());
TreeGridField widthField = new TreeGridField("width", constants.width());
TreeGridField heightField = new TreeGridField("height", constants.height());
TreeGridField weightField = new TreeGridField("weight", constants.weight());
TreeGridField volumeField = new TreeGridField("volume", constants.volume());
TreeGridField latestHandlingTimeField = new TreeGridField("latestHandlingTime", constants.latestHandlingTime());
latestHandlingTimeField.setCanEdit(false);
treeGrd.setFields(idField, businessKeyField, typeField, categoryField,
incomingContainerField, outgoingContainerField, originField, destinationField, productCodeField, lengthField, widthField,
heightField, weightField, volumeField, latestHandlingTimeField);
return treeGrd;
Code:
{
"response":{
"status":0,
"startRow":0,
"endRow":0,
"totalRows":0,
"invalidateCache":false,
"data":{
"changeIdent":null,
"id":921,
"businessKey":"theNode",
"type":null,
"incomingContainer":null,
"outgoingContainer":null,
"destination":null,
"origin":null,
"productCode":null,
"length":null,
"width":null,
"height":null,
"volume":null,
"weight":null,
"category":null,
"incomingBatchBusinessKey":"RD 1000_20150302_1114_Batch 2 FRA",
"outgoingBatchBusinessKey":null,
"latestHandlingTime":null
}
}
}
SmartClient Version: v10.0p_2014-11-26/Pro Deployment (built 2014-11-26)
Firefox 36.0.1