I have an MVVM Grid that is getting data from a WCF service. It all works apart from the format of the data that arrives at the datasource. The json is
{"GetRequestSummaryRestResult":"{\"Data\":[{\"Id\":0.0,\"RequestId\":121.0,\"Creator\":\"Elmer Fudd\",\"Recipient\":\"Bugs Bunny\",\"Assignee\":null,\"RequestType\":\"EquipmentLoan\",\"Description\":\"Mobile phone with the Android operating system\",\"CreationDate\":\"2015-01-14T10:45:09\",\"Status\":null,\"Comments\":null},{\"Id\":1.0,\"RequestId\":2.0,\"Creator\":\"Porky Pig\",\"Recipient\":\"Tweety Pie\",\"Assignee\":null,\"RequestType\":\"EquipmentAcquisition\",\"Description\":\"Holds the laptop at eye height\",\"CreationDate\":\"2014-06-03T11:27:38\",\"Status\":null,\"Comments\":\"me has\"}],\"Total\":11}"}. For some reason the Data and Total are wrapped in an object that is the name of the WCF Service method plus the word Result. I have gotten around it by adding the following to the schema part of the datasource definition:
schema: { data: function (data) { return jQuery.parseJSON(data.GetRequestSummaryRestResult).Data; }, total: function (data) { return jQuery.parseJSON(data.GetRequestSummaryRestResult).Total; }, model: requestsummary },Is this the expected behaviour and is my solution the best way to deal with it? Please let me know.
Thanks