kendo.aspnetmvc.js does not account for server aggregates serialized with came case property names like it does for Groups.
Can the following code (minus the comments) be included in a future release to resolve this?
function translateAggregateResults(aggregate) {
var obj = {};
// LSS: support for camel case serialization
obj[(aggregate.AggregateMethodName || aggregate.aggregateMethodName).toLowerCase()] = (aggregate.Value || aggregate.value);
return obj;
}
function translateAggregate(aggregates) {
var functionResult = {}, key, functionName, aggregate;
for (key in aggregates) {
functionResult = {};
aggregate = aggregates[key];
for (functionName in aggregate) {
functionResult[functionName.toLowerCase()] = aggregate[functionName];
}
aggregates[key] = functionResult;
}
return aggregates;
}
function convertAggregates(aggregates) {
var idx, length, aggregate;
var result = {};
for (idx = 0, length = aggregates.length; idx < length; idx++) {
aggregate = aggregates[idx];
// LSS: support for camel case serialization
result[(aggregate.Member || aggregate.member)] = extend(true, result[(aggregate.Member || aggregate.member)], translateAggregateResults(aggregate));
}
return result;
}
extend(true, kendo.data, {
schemas: {
'aspnetmvc-ajax': {
groups: function (data) {
return $.map(this._dataAccessFunction(data), translateGroup);
},
aggregates: function (data) {
data = data.d || data;
// LSS: support for camel case serialization
var aggregates = data.AggregateResults || data.aggregateResults || [];
if (!$.isArray(aggregates)) {
for (var key in aggregates) {
aggregates[key] = convertAggregates(aggregates[key]);
}
return aggregates;
}
return convertAggregates(aggregates);
}
}
}
});