Reputation: 762
I am new in breeze and i am trying delete a entity using this code:
export var deleteRow= function (selectedRow) {
isDeleting(true);
selectedRow.entityAspect.setDeleted();
(<any>datacontext).saveChanges()
.done(
function () {
router.replaceLocation(listUrl);
})
.fail(saveFailed);
//}
isDeleting(false);
};
and the datacontext is:
export var saveChanges = function () {
return manager.saveChanges()
.then(saveSucceeded)
.fail(saveFailed);
function saveSucceeded(saveResult) {
log('Saved data successfully', saveResult, true);
}
function saveFailed(error) {
var msg = 'Save failed: ' + getErrorMessages(error);
logError(msg, error);
error.message = msg;
throw error;
}
};
The error happend in line:
selectedRow.entityAspect.setDeleted();
The log (chrome console) tell something about:
"Uncaught Error: Unable to parse bindings. Message: TypeError: Cannot call method 'dictionary' of null; Bindings value: text: row.assessmentType().dictionary().name "
the object row it's alias used in my markup to identify a row in my collection:
<!-- ko foreach: { data: assessmentRegistrations(), as: 'row' }-->
<tr data-bind="css: { koAssumptionGridViewRow: true }, style: { color: 'inherit' }">
<td><small data-bind="text: row.toShortDate"></small></td>
<td><small data-bind="text: row.fishgroup().fishgroupName"></small></td>
<td><small data-bind="text: row.assessmentType().dictionary().name"></small></td>
<td><small data-bind="text: row.site().name"></small></td>
<td><small data-bind="text: row.site().name"></small></td>
<td></td>
<td><small data-bind="text: row.assessmentFollowUpStatus().dictionary().name"></small></td>
</tr>
any help is apreciated :)
Upvotes: 1
Views: 1043
Reputation: 17052
Not sure what the issue is but I would try to isolate it first. i.e. without involving any knockout binding try to call setDeleted(). My bet is that this will succeed. If so, then you know that the issue is a knockout binding issue.
Another possibility: Is it possible that the issue is actually occurring AFTER the saveChanges() call? The reason why this would make sense given your symptoms is that a 'deleted' entity becomes 'detached' after a saveChanges() call and binding to it is very likely to fail.
Upvotes: 2