0

请帮助我,我被 kendoTreeList 的聚合所困扰 - 我创建了 kendoTreeList,但未能计算组的总和。

$(document).ready(function () {
            var _jsondata = [
                      { ID: 1, Name: "Parent 1", Amount: "200", parentId: null },
                      { ID: 2, Name: "Parent 2", Amount: "500", parentId: null },
                      { ID: 11, Name: "Child 11", Amount: "50", parentId: 1 },
                      { ID: 12, Name: "Child 12", Amount: "150", parentId: 1 },
                      { ID: 21, Name: "Child 21", Amount: "100", parentId: 2 },
                      { ID: 22, Name: "Child 22", Amount: "200", parentId: 2 },
                      { ID: 23, Name: "Child 23", Amount: "200", parentId: 2 }                          
                    ];
            var dataSource = new kendo.data.TreeListDataSource({
                data    : _jsondata,
                schema  : { model: { id: "ID", expanded: true }},
                aggregate   : [
                    { field: "Amount", aggregate: "sum"}
                ]
            });
            $("#treelist").kendoTreeList({
                dataSource  : dataSource,                    
                columns     : [
                    { field: "Name" , nullable: false },
                    { field: "Amount",  footerTemplate: "#= sum #"}
                ]
            });
        });

这给出了结果 -

在此处输入图像描述

4

1 回答 1

1

由于Amount表示为_jsondataas string,您需要将其定义schema.modelnumber

schema: {
    model: { 
        id: "ID",
        expanded: true,
        fields: {
            Amount: { type: 'number' }
        }
    }
},
于 2016-01-18T07:36:50.717 回答