JSFiddle - React, Tailwind, and code Playground

by valchev

HTML

<script src="http://cdn.kendostatic.com/2012.1.515/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.default.min.css">
<div id="grid"></div>

JavaScript

var dataRecords = [{foo:1, bar: 1}, {foo:3, bar: 5}];
var emptyData = [];

var ds = new kendo.data.DataSource({
    //data: dataRecords,
    data: emptyData, //sum is undefined when no records
    schema: {
        model: {
            fields: {
                foo: {type: "number"},
                bar: {type: "number"}
            }
        }            
    },
    aggregate: [
        {field: 'foo', aggregate: 'sum'},
        {field: 'bar', aggregate: 'sum'}
    ]
});
    
$("#grid").kendoGrid({
    dataSource: ds,
    columns: [
        {
            field: "foo",
            footerTemplate: "count:#= typeof sum != 'undefined' ? sum : 0 #"
        },
        {
            field: "bar",
            footerTemplate: "count:#= typeof sum != 'undefined' ? sum : 0 #"
        }
    ]
});