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

[Solved] Custom label for group?

5 Answers 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Blendea
Top achievements
Rank 1
Daniel Blendea asked on 24 Aug 2011, 11:20 AM
Hi,

I'm using the MVC Grid with grouping and the group header contains the name of the grouping field and the value.
Is it possible to specify a custom label instead of the field name?

code:
.Groupable( settings => settings.Groups( groups =>
                       {
                           groups.Add( od => od.ProductName);
                       } ).Visible( false ) )

actual result:
-> Product Name: Coffee
---> product row
desired result:
-> Coffee (Starbucks)
---> product row

And the code would look like:
.Groupable( settings => settings.Groups( groups =>
                       {
                           groups.Add( od => od.ProductName).WithLabel("$item.Title (Starbucks)");
                       } ).Visible( false ) )
Thanks,
Daniel

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Aug 2011, 11:55 AM
Hi Daniel Blendea,

 You can use the GroupHeaderTemplate (ClientGroupHeaderTemplate for ajax binding) to do the same. Check the ajax aggregates demo:

columns.Bound(o => o.UnitsInStock)
        .Aggregate(aggregates => aggregates.Count())
        .ClientGroupHeaderTemplate("<#= Title #>: <#= Key #> (Count: <#= Count #>")
Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Daniel Blendea
Top achievements
Rank 1
answered on 24 Aug 2011, 02:49 PM
Hi,
Using GroupHeaderTemplate I can make it display only the value of the grouping property, however, to be displayed, I have to bind also a column for the property used for grouping.
Which is kinda nonsense, because if I display the value in the grouping header, then I don't need it in the row.

If I set the column to Visible(false) the custom template in the group header is not displayed anymore.
0
Atanas Korchev
Telerik team
answered on 24 Aug 2011, 02:55 PM
Hi Daniel Blendea,

This is the only possible solution right now. You can make the column Hidden() instead of Visible(false). Make sure that column is last though because IE can support hidden columns only when they are last.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Daniel Blendea
Top achievements
Rank 1
answered on 24 Aug 2011, 03:02 PM
Yes, Hidden() is doing the job, for now.

Thank you.
0
Levi
Top achievements
Rank 1
answered on 08 Nov 2011, 12:59 AM
Hi Atanas,

I'm not sure <#= Count #> is valid in ClientGroupHeaderTemplate as it doesn't work for me.

-Levi

Edit:
Weird, It does show usage of it in the demo, but when adding the <#= Count #> in my  existing ClientGroupHeaderTemplate that uses Key and Value, it causes the loading of the ajax for the grid to hang...
Tags
Grid
Asked by
Daniel Blendea
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Daniel Blendea
Top achievements
Rank 1
Levi
Top achievements
Rank 1
Share this question
or