I would like to create aggregate calculations like in the example picture.
1) Is this possible with an aggregate field or;
2) Should I use the Change event and manipulate the model directly?
Here is the code for the datasource:
var dataSource = new kendo.data.TreeListDataSource({
transport: {
read: {
url: "../getModelTargetWeights?SSM_id=" + id,
dataType: "json"
}
},
schema: {
parse: function (response) {
NodeArray = [];
if (response.length == undefined) {
var node = {
id: response.id,
currWeight: response.currWeight,
tgtWeight: response.tgtWeight,
hasChildren: response.hasChildnode,
parentId: response.parent,
ext_model_id: response.ext_model_id,
securitySelectionModelName: response.SSM.securitySelectionModelName,
classificationNameNode: response.classificationNameNode,
};
NodeArray.push(node);
} else {
for (var i = 0; i < response.length; i++) {
var node = {
id: response[i].id,
currWeight: response[i].currWeight,
tgtWeight: response[i].tgtWeight,
hasChildren: response[i].hasChildnode,
parentId: response[i].parent.id,
ext_model_id: response[i].ext_model_id,
securitySelectionModelName: response[i].SSM.securitySelectionModelName,
classificationNameNode: response[i].classificationNameNode.classificationName
}
NodeArray.push(node);
}
}
return NodeArray;
},
model: {
id: "id",
parentId: "parentId",
hasChildren: false,
fields: {
id: {type: "number", nullable: false},
parentId: {field: "parentId", type: "number", defaultValue: null},
hasChildren: {type: "boolean", field: "hasChildren"},
tgtWeight: {type: 'number', editable: true},
currWeight: {type: "number", editable: false},
classificationNameNode: {type: "string", editable: false},
securitySelectionModelName: {type: "string", editable: false }
}
},
aggregate: [
{field: "currWeight", aggregate: "sum"},
{field: "tgtWeight", aggregate: "sum"},
]
}
});