我无法让网格聚合在MVVM中使用kendo ui
我一直收到错误'count is not defined'
我有一个演示here
答案 0 :(得分:2)
答案 1 :(得分:-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>