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

Group header title to display count of grouped items

6 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 1
Iron
Ricky asked on 04 Mar 2019, 06:31 PM

Hi,

I see no way to modify the group header template. I don't want to have to alter our data (which I've seen as a proposed solution) or use HeaderCell's, but instead display the total of items grouped in the header. Even better is a way to change the group header title to whatever title we like.

For example, if our dataset contained customers and their orders, we would want to group by customer name and have the number of their grouped orders in brackets in the header title, e.g.:

Customer 1 (3)

Order 1

Order 2

Order 3

Customer 2 (2)

Order 4

Order 5

 

etc. Is this possible?

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 05 Mar 2019, 08:10 AM
Hello, Ricky,

Currently, the supported and recommended approach is to set this inside the data, as the value is shown there is the one inside the actual data collection.

If there is a limitation to this approach in the real application, I made a feature request for the groupHeaderTemplate that will provide the desired option:

https://feedback.telerik.com/kendo-react-ui/1398806-groupheadertemplate

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stefan
Telerik team
answered on 07 Mar 2019, 09:19 AM
Hello, Ricky,

After more research, I found a better approach with the cellRender.

Please take a look at it and advise if it is acceptable:

https://stackblitz.com/edit/react-hdeimf-dqwki5?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ricky
Top achievements
Rank 1
Iron
answered on 19 Mar 2019, 10:47 AM
Hi, sorry for the delay in response.This almost worked but you'll see if you try and group more than one field an error occurs. My React knowledge is still very new so not entirely sure how to fix this?
0
Ricky
Top achievements
Rank 1
Iron
answered on 19 Mar 2019, 10:48 AM
(I used the other approach as mentioned in the thread that was linked, and this worked and also worked with subgroups, so if the cellRender can work the same I would prefer that approach)!
0
Stefan
Telerik team
answered on 20 Mar 2019, 09:22 AM
Hello, Ricky,

Thank you for reporting the issue.

In this case, we have to check if the td actually has children as well. After adding this to the if statement, the approach is working with multiple groups:

https://stackblitz.com/edit/react-hdeimf-dqwki5?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ricky
Top achievements
Rank 1
Iron
answered on 20 Mar 2019, 09:24 AM
Thanks Stefan, all is working. Thanks for your replies, I'm sure it'll help others too.
Tags
General Discussions
Asked by
Ricky
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Ricky
Top achievements
Rank 1
Iron
Share this question
or