如何在剑道网格UI中显示sum groupFooterTemplate

时间:2018-07-03 08:47:10

标签: javascript knockout.js kendo-ui kendo-grid

我有数据并在剑道网格中与组一起显示。每个组(发票编号-VGBEL)都有一个groupFooterTemplate,但“数量(LFIMG)”列始终为0,00。我需要每个页脚的数量总和。我的错误在哪里?我在互联网上搜索,但未找到解决方案。我知道有一个小错误,但我没有发现。

这是我的JS代码。

var kendoResource = getKendoResourceOptions();

            options.columns[0].groupFooterTemplate = 'Sipariş Toplamı:'; 

            options.columns[8].groupFooterTemplate = '#: data.LFIMG ? kendo.format("{0:C2}",data.LFIMG.sum): 0,00 #';  


            $("#grid").kendoGrid({
                        toolbar: [{ name: "excel", text: kendoResource.toolbar.messages.excel }],
                        excel: {
                            fileName: "DeliveryList.xlsx",
                            allPages: true,
                            filterable: true
                        },

                        groupable: kendoResource.groupable,
                        scrollable: true,
                        sortable: true,
                        pageable: kendoResource.pageable,
                        columns: options.columns
                    });


        self.filterClick = function () {
            showLoading();
            mbisPost('Reports.Summary', "/api/TermoTeknikReportApi/DeliveryList", ko.toJS(self.filters), function (result) {
                if (result && result.length > 0) {                
                    self.showNoDataToDisplay(false);
                    
                var dataSource = new kendo.data.DataSource({
                                  data: result,                      
                                  pageSize: 100,
                                  group: {
                                        field: "VGBEL",
                                    },
                                  aggregate: [
                                      { field: "LFIMG", aggregate: "sum" }
                                    ]
                                });

                var grid = $("#grid").data("kendoGrid");
                grid.setDataSource(dataSource); 

                    // element for which the tooltip is shown
                    grid.thead.kendoTooltip({
                        filter: "th",
                        content: function (e) {
                            var target = e.target; 
                            return $(target).text();
                        }
                    });
        
                }
                else {
                    self.showNoDataToDisplay(true);
                }

            }).error(function () { hideLoading(); }).done(function () { hideLoading(); });
        }

网页的截图

enter image description here

1 个答案:

答案 0 :(得分:1)

我更改了dataSource代码。将“聚合”属性放入组

var dataSource = new kendo.data.DataSource({
                                  data: result,                      
                                  pageSize: 100,
                                  group: {
                                        field: "VGBEL",
                                        aggregates: [ { field: "LFIMG", aggregate: "sum" },{ field: "LFIMG_M", aggregate: "sum" }]  // this line
                                    },
                                  aggregate: [
                                      { field: "LFIMG", aggregate: "sum" },{ field: "LFIMG_M", aggregate: "sum" } 
                                    ]
                                });