如果我创建一个隐藏列,在这种情况下为BirthDateMonth并从数据集创建它,如果我还在另一个字段上添加组聚合,那么它将打破JS错误“sum not定义为“。具有隐藏列和聚合的Kendo UI网格
var grid = $("#grid").kendoGrid({
dataSource: {
data: createRandomData(10),
schema: {
model: {
fields: {
FirstName: { type: "string" },
LastName: { type: "string" },
City: { type: "string" },
Title: { type: "string" },
BirthDate: { type: "date" },
//BirthDateMonth: { type: "date" },
Age: { type: "number" }
},
},
parse: function (data) {
$.each(data, function (idx, item) {
if (item.BirthDate)
{
item.BirthDateMonth = new Date(item.BirthDate.getTime());
item.BirthDateMonth.setDate(1);
}
});
return data;
}
},
pageSize: 10,
aggregate: [
{field: "Age", aggregate: "sum"}
]
},
height: 500,
scrollable: true,
groupable: true,
columns: [
{
field: "FirstName",
title: "First Name"
},
{
field: "LastName",
title: "Last Name"
},
{
field: "City",
},
{
field: "Title"
},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
},
{
field: "BirthDateMonth",
title: "Birth Month",
template: '#= kendo.toString(BirthDateMonth,"MM/yyyy") #',
hidden: true
},
{
field: "Age",
aggregates: ["sum"],
footerTemplate: "Sum: #=sum#",
groupFooterTemplate: "Sum: #=sum#"
}
]
}).data("kendoGrid");
grid.dataSource.group([{field: "BirthDateMonth"}]);
JSFiddle,任何想法赞赏。我试图向模式添加隐藏列字段,但没有效果。
是的,谢谢。 – Stuart