Aggregates and footertemplates are too restrictive

3 posts, 0 answers
  1. Robert
    Robert avatar
    35 posts
    Member since:
    Feb 2012

    Posted 12 May 2015 Link to this post

    We are trying to convert from using the normal kendo grid to using a tree list grid for one of our features.

    With the normal grid when the footertemplate is executed it is provided the full set of aggregates from the datasource. This allows us to perform a calculation from two different aggregates and apply to custom html.

    The tree list footertemplate is called with the aggregate for that column / field only, it is wrapped in a way that you cannot access the rest of the aggregate object even though they are available in the datasource. Because we are using shared templates it is not convenient to go to the datasource by #element to get the rest of the aggregates. The IIF that wraps the execution of the template is not called with the context of the datasource being 'this' so we are not able to get any more information but the individual field aggregate.

    Why can't the two grids / datasources work the same way with footertemplates?

    Thanks,

    Rob.

  2. Robert
    Robert avatar
    35 posts
    Member since:
    Feb 2012

    Posted 12 May 2015 Link to this post

    For those who have the same problem, I have come up with a workaround (hack) which merges the single field aggregate with that of it's parent object (all the aggregates for that parent)

    In the TreeListDataSource options object, set the change: property to the following:

    (warning: this uses lodash.js for the _.keys, _.forEach and _.assign  -  the equivalent can be done in vanilla javascript)

     

    change: function () {

            var agg = this._aggregateResult;
            if (!agg) return;
            // each tree root
            _.forEach(_.keys(agg), function (parentId) {
                // map full aggregate to each field (property merged with it's parent)
                _.forEach(_.keys(agg[parentId]), function (key) {
                    agg[parentId][key] = _.assign(agg[parentId][key], agg[parentId]);
                });
            });
    },

     

  3. Kendo UI is VS 2017 Ready
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 14 May 2015 Link to this post

    Hello Robert,

    Indeed currently the TreeList aggregates doesn't support this. You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top