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
You can use the GroupHeaderTemplate (ClientGroupHeaderTemplate for ajax binding) to do the same. Check the ajax aggregates demo:
columns.Bound(o => o.UnitsInStock)Regards,
.Aggregate(aggregates => aggregates.Count())
.ClientGroupHeaderTemplate("<#= Title #>: <#= Key #> (Count: <#= Count #>")
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 >>
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.
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 >>
Thank you.
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...