This is a migrated thread and some comments may be shown as answers.

Aggregates and footertemplates are too restrictive

2 Answers 105 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 12 May 2015, 08:52 AM

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 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 12 May 2015, 10:25 AM

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]);
            });
        });
},

 

0
Nikolay Rusev
Telerik team
answered on 14 May 2015, 07:30 AM

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!
 
Tags
TreeList
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or