剑道网格,虚拟滚动,页面大小和聚合

本文关键字:网格 虚拟 滚动 | 更新日期: 2023-09-27 18:19:45

当我为具有用页面大小定义的数据源的剑道网格打开虚拟滚动时,当我滚动并进行虚拟分页时,它会更改聚合页脚模板中的总计,以匹配页面大小中的总计。最初创建栅格时,这些值是正确的。有没有一种方法可以锁定这些聚合值,这样当虚拟分页发生时它们就不会改变?

剑道网格,虚拟滚动,页面大小和聚合

使用MVC

请尝试使用以下链接。http://developerom.blogspot.in/2012/12/how-to-use-aggregate-function-in-kendo.html

如果有任何顾虑,请告诉我。

使用Jquery

<div id="grid">
</div>
<script>

function onDataBound(arg) {
    var UnitPrice = 0; // sum
    var UnitsOnOrder = 0; //average
    var total = arg.sender.dataSource._data.length; // total
    for (var i = 0; i < total; i++) {
        UnitPrice += parseInt(arg.sender.dataSource._data[i].UnitPrice);
        UnitsOnOrder += parseInt(arg.sender.dataSource._data[i].UnitsOnOrder);
    }
    $("#spanProductNamefooter").html('Total count: '+total);
    $("#spanUnitPricefooter").html('Sum: '+UnitPrice);
    $("#spanUnitsOnOrderfooter").html('average: '+parseInt(UnitsOnOrder/total));
}
function onDataBinding(arg) {
}
$(document).ready(function () {
    $("#grid").kendoGrid({
        dataSource: {
            type: "odata",
            transport: {
                read: "http://demos.kendoui.com/service/Northwind.svc/Products",
                dataType: "jsonp",
            },
            schema: {
                model: {
                    fields: {
                        UnitsInStock: { type: "number" },
                        ProductName: { type: "string" },
                        UnitPrice: { type: "number" },
                        UnitsOnOrder: { type: "number" },
                        UnitsInStock: { type: "number" }
                    }
                }
            },
            pageSize: 7,
            aggregate: [{ field: "ProductName", aggregate: "count" },
                                      { field: "UnitPrice", aggregate: "sum" },
                                      { field: "UnitsOnOrder", aggregate: "average" },
                                      { field: "UnitsInStock", aggregate: "min" },
                                      { field: "UnitsInStock", aggregate: "max"}]
        },
        sortable: true,
        height: 430,
        dataBound: onDataBound,
        dataBinding: onDataBinding,
        scrollable: {
            virtual: true
        },
        columns: [
                        { field: "ProductName", title: "Product Name", footerTemplate: "<span id='spanProductNamefooter'></span>"},
                        { field: "UnitPrice", title: "Unit Price",footerTemplate: "<span id='spanUnitPricefooter'></span>" },
                        { field: "UnitsOnOrder", title: "Units On Order", footerTemplate: "<span id='spanUnitsOnOrderfooter'></span>"},
                        { field: "UnitsInStock", title: "Units In Stock"}
                    ]
    });
});
</script>

如果有任何顾虑,请告诉我。