kendo grid mvvm agregate

2 posts, 0 answers
  1. Neeraj
    Neeraj avatar
    139 posts
    Member since:
    May 2015

    Posted 05 Feb 2019 Link to this post

            How to use aggregate function in kendo mvvm grid and limit sum to 2 decimal places. sum is applied in Original Amount . Its MVVM and console error displays sum is not defined

    <div data-role="grid" id="IGrid"
                    { "field": "Description", title: "Description"},
                      "field": "OriginalAmount", title: "Amount", width: "100px",  editable: function () {  return false; }, template: kendo.template($("\\#GstAmount").html()),
                       footerTemplate: "Total: #=sum#")
                    data-bind='source: GST.GSTBreakup ,events: {dataBound: parent().GridDataBound}'
                    style="height: 200px"></div>
  2. Alex Hajigeorgieva
    Alex Hajigeorgieva avatar
    1082 posts

    Posted 05 Feb 2019 Link to this post

    Hello, Neeraj,

    The described behaviour is expected for MVVM bound grids as they are created with an empty data source initially which is without aggregates. This is explained in detail in the documentation:

    The solution is to provide a condition in the template, e.g.:

    { "field": "OriginalAmount", "footerTemplate": "Total: #: data.OriginalAmount? kendo.toString(sum, \"c2\"): 0 #" }

    The template above will also show the sum formatted as currency with the help of the kendo.toString() method:

    Kind Regards,
    Alex Hajigeorgieva
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top