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

Setting Kendo UI Grid Group Header Template value with angularjs

4 Answers 648 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andres
Top achievements
Rank 1
Andres asked on 25 Mar 2015, 11:38 PM
I'm fairly new to Kendo UI/Angular and I've run into a problem which I hope is not a biggie.Basically I want to allow users to dynamically create a grid.. that means setting data source, selecting columns.. grid options etc.The data source (which is SharePoint but it ain't part of the issue...) can sometime bring a "user" field which is the id of the user rather than the name. So after doing a little bit of research I opted to use column template function to get the actual name.Below is a portion of the Column object function that I use to dynamically create columns which will be pushed into an array.The piece of code that sets template works like a charm. However, if the grid has grouping enabled, when this column is dragged to be grouped by, then it shows the id. So I thought - too easy, I'm just going to do the same thing for the groupHeaderTemplate.. but it didn't work :( .It appears that this portion of the code * dataItem." + userId + " * is not valid when grouping. It just sends an undefined to the function. I've tried different things.. like use 'value', which kendo uses in some of their examples.. but no party so far.

Any help would be greatly appreciated!

function Column(Field, Title, Type) {
if(Type == "User"){
var userId = Field + "Id";
this.field = userId
this.template = "<span ng-bind=getUserName(dataItem." + userId + ")></span>";
this.groupHeaderTemplate = "<span ng-bind=getUserName(Dont Know What to put here)></span>";
} .....
}

 

Btw. when debugging this thing, I noticed that the getUSerName function gets call an stupid amounts times when rendering the grid. Is this normal? or am I doing something wrong? I'm a bit concern about the impact it could have on the performance. I mean, my test data source had 3 results, but the function was being called like 15 times.. odd.

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 30 Mar 2015, 06:36 AM
Hello Andres,

From the provided information it's not clear for us what is the exact configuration that you are using - could you please modify the following example in order to reproduce the issue and send it back to us? 
Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
sprytherch
Top achievements
Rank 1
answered on 13 Mar 2018, 01:25 PM

Hello,

I'm having trouble getting aggregates working in groupHeaderTemplates. I took your example and tried to show the extension as a sum next to the EmployeeID but not working yet !   

 

http://dojo.telerik.com/eqImaqIV

 

0
sprytherch
Top achievements
Rank 1
answered on 14 Mar 2018, 07:58 PM

Here's a simpler question. In this:   http://dojo.telerik.com/eqImaqIV/8

If you change the word groupFooterTemplate to groupHeaderTemplate, shouldn't it work ?

0
Stefan
Telerik team
answered on 15 Mar 2018, 08:02 AM
Hello, Stephen,

Thank you for the example.

When the AngularJS templates are used the syntax could be a little bit different.

In this case, the actual aggregates have to be accessed from the dataItem passed to the group.

I modified the example to show the aggregates value in groupHeaderTemplate:

http://dojo.telerik.com/eqImaqIV/11

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Andres
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
sprytherch
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or