Summing columns or do custom calculations

4 posts, 0 answers
  1. axwack
    axwack avatar
    37 posts
    Member since:
    Aug 2012

    Posted 22 Jan 2016 Link to this post

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

  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2286 posts

    Posted 27 Jan 2016 Link to this post

    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!
     
  3. axwack
    axwack avatar
    37 posts
    Member since:
    Aug 2012

    Posted 25 Feb 2016 in reply to Nikolay Rusev Link to this post

    Can a validation be done on the number in the cell?
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2286 posts

    Posted 29 Feb 2016 Link to this post

    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!
     
Back to Top