Suppose I have a data source with fields id and x that comes from a table foobar.
The view model is id, x, xorig. For read operations the xorig value is also set to the x value
The peculiar rules for foobar is that when an x is to be updated it will try to honor the requested x, otherwise it will return a new x value
The data source is configured for batch mode.
The read gets a row id=1, x=10
The user edits x to be 20 and hits a save changes button. The update transport sends json via parameterMap [ {id:1, x:20, xorig:10} ]
The update routine will send back [ {id:1, x:20, xorig:20} ] if the edit was honored, or perhaps [ {id:1,x:55,xorig:55} ] if the 20 could not be honored and the peculiar rules determined x should be 55 instead.
How and where can I capture the update response and tweak the data source elements to match the update response. For example:
for
(
var
i=0; i<updateResponseData.length; i++) {
var
responseItem = updateResponseData[i];
var
datasorcItem = myDataSource.get(responseItem.id);
datasorcItem.x = responseItem.x;
datasorcItem.xorig =responseItem.xorig;
datasorcItem.dirty =
false
;
}
Thanks,
Richard