Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error is thrown when using aggregates in ClientGroupFooterTemplate in a Grid with external DataSource #7810

Open
kendo-bot opened this issue Apr 23, 2024 · 0 comments

Comments

@kendo-bot
Copy link
Contributor

kendo-bot commented Apr 23, 2024

Bug report

When the Grid uses an external DataSource, the aggregates are undefined within the ClientGroupFooterTemplate().

Reproduction of the problem

Use the following REPL sample that demonstrates the issue:

https://netcorerepl.telerik.com/mIkyQnvB382bsiFt24

  1. Group the Grid by the "Freight" column.

  2. An error is thrown in the browser console: "Uncaught ReferenceError: sum is not defined".

  3. The aggregates=["sum"] is missing in the column options in the Grid initialization script;

"columns":[{"title":"Order ID","field":"OrderID","filterable":false,"encoded":true},**{"title":"Freight","groupFooterTemplate":"Sum: #=sum#","field":"Freight","filterable":{"messages":{"title":"Show items with value that"},"checkAll":false},"encoded":true}**,{"title":"Ship City","width":"150px","field":"ShipCity","filterable":{"messages":{"title":"Show items with value that"},"checkAll":false},"encoded":true}]

When the DataSource is defined within the Grid configuration, the aggregate is displayed as expected.

Expected/desired behavior

The "sum" aggregate must be displayed within the group footer template of the column when the Grid is grouped.

Workaround

Define the DataSource in the Grid configuration or update the Grid settings by using the setOptions() method when the page is loaded:

<script>
    $(document).ready(function () {
        var grid = $("#grid").data("kendoGrid");
        if (grid) {
            let gridColumns = grid.columns;
            if (!gridColumns[1].aggregates) { // update [1] with the index of the column that has a group footer template. For example, "1" is the 2nd Grid column
                gridColumns[1].aggregates = ["sum"];
                grid.setOptions({ columns: gridColumns });
            }
        }
    });
</script>

Environment

  • **Telerik UI for ASP.NET Core/MVC: 2024.1.319
  • **Browser: [all]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants