简体   繁体   English

通过列值在页脚模板中的Kendo-grid自定义聚合

[英]Kendo-grid custom aggregate in footer template by columns values

I have a large grid and I need to add a count in the footer, to calculate count of non-nullable and not empty cells in column, but standart count aggregate gives only completed total count result. 我有一个很大的网格,我需要在页脚中添加一个计数,以计算列中不可为空且不能为空的单元格的计数,但是标准计数聚合只给出完整的总计数结果。 In custon templates I find ability only for using these completed aggregation functions (min, max, sum, count...). 在custon模板中,我发现只能使用这些完成的聚合函数(最小,最大,总和,计数...)。 Is there any ideas how to count only filled cells in column and display result in footer of grid? 有什么想法如何只计算列中的填充单元格并在网格的页脚中显示结果吗?

You can configure the columns.footerTemplate property as a function, and use some custom logic to count the non-null fields, then display it in the footer of the respective column, eg: 您可以将column.footerTemplate属性配置为一个函数,并使用一些自定义逻辑来计算非null字段,然后将其显示在相应列的页脚中,例如:

Example

If someone interests how I have solved it, I will answer in general. 如果有人对我的解决方法感兴趣,我通常会回答。

I have created custom column in result's data (before binding it to grid) with values 1 or 0: 1 - if I want to count current row in result; 我已经在结果的数据中创建了自定义列(在将其绑定到网格之前),其值是1或0:1-如果我想计算结果中的当前行; 0 - if I don't. 0-如果我不知道。 Then I have used sum aggregate function for this column instead count . 然后,我在此列中使用了sum合计函数,而不是count And then I just only have not displayed this column in grid for users. 然后,我只是没有为用户显示此列在网格中。

This approach gives ability to write your custom logic outside of kendo footer template, you just use count (in this case sum ) for results of your custom logic. 这种方法使您能够在kendo页脚模板之外编写自定义逻辑,您只需对自己的逻辑结果使用count (在这种情况下为sum )。

All other approaches and solutions, which I've tried did not help. 我尝试过的所有其他方法和解决方案都无济于事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM