CMS
CMS

Reputation: 3757

kendo mvvm grid aggregate error

I can't get the grid aggregates to work in kendo ui with MVVM I keep getting an error 'count is not defined' I have a demo here

Upvotes: 1

Views: 471

Answers (2)

Veeresh Hawaragi
Veeresh Hawaragi

Reputation: 1

<div id="example">
    <div data-role="grid" data-row-template="RowTemplate"
        data-columns="[
                        { 'field': 'Name', 'title': 'Name',  'footerTemplate': 'Total'},               
                        { 'field': 'Amount', 'title': 'Amount',  'footerTemplate': '#=kendo.toString(data.Amount ? data.Amount.sum : 0, \'c\')#'}
                      ]"
        data-bind="source: AmountData">
    </div>
</div>
<script id="RowTemplate" type="text/x-kendo-template">   
        <tr>                    
            <td>#= Name # </span></td>          
            <td class="text-right">#if(Amount==0){# #}else{##=kendo.toString(Amount, "c2")##}#</td>          
        </tr>
</script>

<script>
    $(document).ready(function () {
        var viewModel = kendo.observable({

            AmountData: new kendo.data.DataSource({
                type: "Json",
                data: [{ Name: "abc", Amount: 1000 },
                       { Name: "xyz", Amount: 2500 },
                       { Name: "lmn", Amount: 1700 }],
                aggregate: [{ field: "Amount", aggregate: "sum" }]
            })
        });

        kendo.bind($("#example"), viewModel);
    });
</script>

Upvotes: -1

Alag
Alag

Reputation: 1408

The problem is not with aggregartes but with footer template.

Working demo here

I refer to this question, please see not accepted answer, it is what you need.

Upvotes: 2

Related Questions