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

GroupHeader field different from Grouping field

3 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaetano
Top achievements
Rank 1
Gaetano asked on 04 Jun 2013, 10:07 AM
Hi,
I have a grid that is grouped by my PropertyField-A (lat-lon position), I would like to show PropertyField-B (address) in group header.
How can I do it? Is it possible? If not, can you suggest me some workaround?
I've tried using columns.headerTemplate but I can't access in the template to the properties of my datasource.

Thanks a lot!
Fabio

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Jun 2013, 07:08 AM
Hello Fabio,

I am not sure if I understand correctly the needed functionality. If the data is grouped by "FieldA" then it is not necessary for the value of "FieldB" to be the same for all items in the group. If it is the same in your scenario then you could access it by using the parent method e.g.

groupHeaderTemplate: "#: data.parent().parent().items[0].FieldB#"

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gaetano
Top achievements
Rank 1
answered on 06 Jun 2013, 09:26 AM
Hi Daniel,
you have correctly understood the issue.
The posted code doesn't work. This is the error:

Uncaught TypeError: Object #<Object> has no method 'parent'

Indeed the data object has only "field" and "value" properties and no methods.
There is another way to access to the property "field-A" of the first item of the group?

Thanks a lot.
Fabio

0
Daniel
Telerik team
answered on 10 Jun 2013, 08:01 AM
Hello Fabio,

I am sorry for misleading you. It is possible to use the parent method to get a different field value only when server grouping is used because the objects will be wrapped when received from the server. I created a small jsBin example that demonstrates this scenario. If client grouping is used then I can suggest to find the item in the dataSource data. I created another jsBin example that demonstrates this approach.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Gaetano
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Gaetano
Top achievements
Rank 1
Share this question
or