JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2011.3.1129/js/kendo.all.min.js"></script>
<div id="grid">
</div>
<div id="log"></div>
JavaScript
var data = [
{
ProductID: 1,
ProductName: "ProductName 1",
Amount: 1
},
{
ProductID: 2,
ProductName: "ProductName 2",
Amount: 2
}
];
function log(dataSource) {
var log = $("#log");
log.html(log.html() + "<br />" + dataSource.aggregates().Amount.sum);
}
$("#grid").kendoGrid({
dataSource: {
data: data,
aggregate: [{ field: "Amount", aggregate: "sum" }],
batch: true,
pageSize: 1,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
Amount: { type: "number"}
}
}
}
},
editable: true,
pageable: true,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName", "Amount"
],
save: function(e) {
var dataSource = this.dataSource;
e.model.one("change", function() {
dataSource.one("change", function() {
log(dataSource);
});
dataSource.fetch();
});
}
});