I need to display the user calculation in the Kendo GUI footer template. Embedded units will not work for business requirements. I found a way to display the results from a function in the footer using the code snippets shown below. The key points in this code are:
- Defined user function calculation (named calc).
- A link to a custom calculation function exists in footerTemplate (i.e. footerTemplate: "Total: # = window.calc () #").
function calc() {
var field = "Value";
var dataSource = window.ds;
var newValue = 0;
$.each(dataSource.data(), function(index, model) {
newValue += model.get(field);
});
return newValue;
}
$(document).ready(function() {
window.ds = new kendo.data.DataSource({
data: [
{Name:"One", Value:1},
{Name:"Two", Value:1},
{Name:"Three", Value:1},
{Name:"Four", Value:1},
{Name:"Five", Value:1}
],
pageSize: 10,
schema: {
id: "Name",
fields: {
Name: { type: "string"},
Value: { type: "number"}
}
}
});
$("#grid").kendoGrid({
dataSource: window.ds,
scrollable: false,
pageable: true,
editable: true,
columns: [
{ field: "Name", title: "Name" },
{ field: "Value", title: "Value",
footerTemplate: "Total: #=window.calc()#" }
]
});
});
, , , " ", . , API- Kendo UI Grid.
, , - Grid, Grid.
$("#grid").kendoGrid({
dataSource: window.ds,
scrollable: false,
pageable: true,
editable: true,
columns: [
{ field: "Name", title: "Name" },
{ field: "Value", title: "Value",
footerTemplate: "Total: #=window.calc()#" }
],
save: function (e) {
e.sender.refresh();
}
});
( ), . , , ( , -, ). , (yuck!).
http://trykendoui.telerik.com/oVEV/4.
, , . - ?