简体   繁体   中英

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...). 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:

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; 0 - if I don't. Then I have used sum aggregate function for this column instead 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.

All other approaches and solutions, which I've tried did not help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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