Kendo UI: Not able to add footerTemplate to grid

旧城冷巷雨未停 提交于 2019-12-23 12:26:38

问题


I am trying to display the count of the field in the footerTemplate. Follow is the fiddle:

http://jsbin.com/ajoyug/8/edit

However, without the footerTemplate it works fine. But as soon as I add the footerTemplate, it stops working.

Inside the aggregateResult object I am getting the value of count. But then how shall I add it to the footerTemplate?

Kindly help me out.

Thanks!!


回答1:


I could not explain why it's not working. But I have tried doing your example by other way and it works well.

Here goes the link.

http://jsbin.com/ajoyug/35/edit




回答2:


The problem is with your approach the grid is rendered twice, the first time on Kendo UI initialization (implicit during the first bind) and the second when you bind the actual data.

The first time the data is still not available and then it fails.

If anyway you want to follow that path you should do:

<div id="myListView" data-role="grid" class="transaction-grid"
     data-columns="[
            { field: 'name', title: 'Name', width:'20%' },
            { 
                field: 'age',
                title: 'Age' , 
                width:'35%', 
                footerTemplate: 'Total Count: # if (data.age) { # #= age.count # # } #'  
            }
            ]"
     data-bind="source: dataSource">
</div>

i.e. check if data.age is available and then is when you print it.

Otherwise, I recommend following @UmankantPatil suggestion and do not use data-* but JavaScript for initializing the widgets and binding data.

Check it in the modified version of your JSBin here



来源:https://stackoverflow.com/questions/16172710/kendo-ui-not-able-to-add-footertemplate-to-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!