剑道UI网格创建聚合函数
Kendo ui grid create aggregate function
有没有办法在剑道中创建聚合函数?
我正在尝试在网格中求和,如果我使用 kendo 定义的 sum 函数,它只是将数字连接起来,就像它们是字符串一样。我的实际解决方案是从剑道更改 js 并放置 mysum 函数。
它就像一个魅力,但我认为应该有更好的解决方案。
查看代码:
var dataSource = new kendo.data.DataSource({
pageSize: 20,
data: products,
autoSync: true,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
Category: { defaultValue: { CategoryID: 1,CategoryName:"Beverages"} },
UnitPrice: { type: "number", validation: { required: true,min: 1} }
}
}
},
aggregate: [ { field: "ProductName", aggregate: "count" },
{ field: "UnitPrice", aggregate: "mysum" }]
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 430,
toolbar: ["create"],
columns: [
{ field: "ProductName", title: "Product Name", footerTemplate: "Total Count: #=count#" },
{ field: "Category", title: "Category", width: "160px", editor: categoryDropDownEditor, template: "#=Category.CategoryName#" },
{ field: "UnitPrice", title:"Unit Price", width: "120px", footerTemplate: "Total Sum: #=mysum#" },
{ command: "destroy", title: " ", width: "90px" }],
editable: true
});
和剑道UI增加了功能:
mysum:function(e,t,n){return (e || 0) + parseFloat(n.get(t))}
你好,我迟到了,但如果它可以帮助某人。
我曾经遇到过同样的问题,我实施了一个解决方案,可以帮助您在 groupFooterTemplate 中使用自定义聚合函数。
链接到此处的项目
function myAggregate(data){
// Data here is a list of data by group (brilliant right! :-) )
// Do anything here and return result string
}
var grid = $('#grid').kendoGrid({
...
columns: [
{ field: '', title: '', groupFooterTemplate: myAggregate
]
...
});
<!DOCTYPE html>
<html>
<head>
<!-- YOUR CSS HERE -->
</head>
<body>
...
<div id="#grid"></div>
...
<script>// jQuery here </script>
<script>// kendo.all.min.js here </script>
<script src="kendo.aggregate.helper.js"></script>
</body>
</html>
相关文章:
- 如何在不使用 new 关键字的情况下从函数创建对象
- 如何使用特定的javascript函数创建一个url,以便在加载页面时运行
- geoTest函数-创建if/else语句
- D3数学函数创建
- Javascript:为函数创建回调
- 如何在追加函数创建后最小化单个框
- 对使用函数构造函数创建的函数的内部引用
- 获取使用函数构造函数创建的函数的名称
- 如何将函数绑定到使用链接函数创建 HTML 的角度指令
- 为什么可以't JavaScript构造函数创建字符串或数字
- 为什么用构造函数创建对象会执行对象's方法
- Jquery 函数创建一个异常的暂停
- JQuery.click,nor.on(“click”,..)与使用函数创建的ASP.NET和twitter boost
- 如何使用javascript函数创建可以调用javascript函数的聚合物元素
- 使用构造函数创建对象和返回对象有区别吗
- 通过父构造函数创建主干继承视图
- 使用构造函数创建的数字没有其值作为属性,请取消String与构造函数的链接
- 如何减少Crossfilter组函数创建的bucket数量
- 从两个单独的函数创建 JQuery 悬停
- 如何访问从函数创建和返回的对象的属性