Refresh Parent Detail After Embedded Grid Save or Delete
Type: JavaScript
(function refreshParentDetail() {
var refreshAfterSave = true, // change to false if you don't want to refresh the parent after save
refreshAfterDelete = true, // change to false if you don't want to refresh the parent after delete
saveSuccessful = (GBHelpers.getParamValue('us') == '1'),
deleteSuccessful = (GBHelpers.getParamValue('dsrc').length > 0),
isFilteringByParentId = (filteringByParent == true),
hasValidFilterByParentField = (GBHelpers.getParamValue('fpf') != ''),
parentDetailId;
if (isFilteringByParentId) {
parentDetailId = GBHelpers.getParamValue('id');
} else if (hasValidFilterByParentField) {
parentDetailId = GBHelpers.getParamValue('fpv');
}
if (isFilteringByParentId || hasValidFilterByParentField) {
if ((refreshAfterSave && saveSuccessful) || (refreshAfterDelete && deleteSuccessful)) {
// reload the detail page
top.location.href = '/' + parentDetailId;
}
}
})();
The filteringByParent variable is global and comes from the Grid page. GBHelpers.getParamValue is a function within the Grid’s JavaScript logic.