This is a migrated thread and some comments may be shown as answers.

Summing columns or do custom calculations

3 Answers 125 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
axwack
Top achievements
Rank 1
axwack asked on 22 Jan 2016, 07:36 PM

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"},
               ]
           }
       });

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 27 Jan 2016, 08:36 AM

Hello Vincent,

 

You should use change event of the model. Here is a quick example - http://dojo.telerik.com/@rusev/OquCa

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
axwack
Top achievements
Rank 1
answered on 25 Feb 2016, 04:18 PM
Can a validation be done on the number in the cell?
0
Nikolay Rusev
Telerik team
answered on 29 Feb 2016, 09:28 AM

Hello axwack,

 

I'm not sure I understand. You can define validatin rules in the model definition. However this is UI validation and the cell must be in edit mode in order to trigger validation check.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeList
Asked by
axwack
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
axwack
Top achievements
Rank 1
Share this question
or