总和在Kendo网格中不起作用

时间:2016-07-14 09:53:03

标签: javascript kendo-grid

我有一个问题是总结预算和余额。这是使用数据源创建kendo网格的代码。

$("#grid").kendoGrid({
           dataSource: vm.dataSource,
           schema: {
              model: {
                 fields: {
                    description: { type: "string" },
                    budget: { type: "number" },
                    balance1: { type: "number" },
                    balance2: { type: "number" },
                    balance3: { type: "number" },
                    balance4: { type: "number" },
                    balance5: { type: "number" },
                    balance6: { type: "number" },
                    balance7: { type: "number" }
                 }
              }
           },
           height: 430,
           group: {
              field: "description", aggregates: [
                { field: "budget", aggregate: "sum" },
                 { field: "balance1", aggregate: "sum" },
                 { field: "balance2", aggregate: "sum" },
                 { field: "balance3", aggregate: "sum" },
                 { field: "balance4", aggregate: "sum" },
                 { field: "balance5", aggregate: "sum" },
                 { field: "balance6", aggregate: "sum" },
                 { field: "balance7", aggregate: "sum" }
              ],
              aggregate: [{ field: "description", aggregate: "sum" },
                { field: "balance1", aggregate: "sum" },
                { field: "balance2", aggregate: "sum" },
                { field: "balance3", aggregate: "sum" },
                { field: "balance4", aggregate: "sum" },
                { field: "balance5", aggregate: "sum" },
                { field: "balance6", aggregate: "sum" },
                { field: "balance7", aggregate: "sum" }]
           },


           filterable: {
              mode: "row"
           },
           pageable: false,

           columns: [
           {
              field: "description",
              width: 150,
              title: "descriptions",
              footerTemplate: "Total (excl. BTW)",
              filterable: {
                 cell: {
                    operator: "contains"
                 }
              },
           }, {
              field: "balance1",
              width: 130,
              title: "balance1",
              aggregates: ["sum"],
              groupFooterTemplate: "Sum: #=sum#",                
              filterable: {
                 cell: {
                    operator: "gte"
                 }
              }
           }, {
              field: "budget",
              width: 130,
              title: "Budget",
              aggregates: ["sum"],
              groupFooterTemplate: "Sum: #=sum#",                
              filterable: {
                 cell: {
                    operator: "gte"
                 }
              }
           }]
        })

对于这个例子,我使用两列来总结。当我使用groupFootertemplate标记时,它不会显示预算或余额的总和。

我用这个来源总结: link

1 个答案:

答案 0 :(得分:0)

修复它!

foo(std::make_pair(1, 1), std::make_pair(1, 2.2),
    std::make_pair(1, std::string("3")));

此代码必须位于数据源内,如下所示:

     aggregate: [{ field: "description", aggregate: "sum" },
            { field: "balance1", aggregate: "sum" },
            { field: "balance2", aggregate: "sum" },
            { field: "balance3", aggregate: "sum" },
            { field: "balance4", aggregate: "sum" },
            { field: "balance5", aggregate: "sum" },
            { field: "balance6", aggregate: "sum" },
            { field: "balance7", aggregate: "sum" }]
       },

}