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

[Solved] Add custom data to group header template

0 Answers 11 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.
Rahul
Top achievements
Rank 1
Rahul asked on 01 May 2013, 06:04 AM
Hello,

I have used Asp.net MVC Grid and have grouped on a column(subject) and used groupheadertemplate to display count of rows.
I want to add custom data from model to the count in header.
How can I do that?

following is the code that I use:

@(Html.Telerik().Grid(Model)
                            .Name("Grid1")
                            .Columns(columns =>
                            {
                                columns.Bound(o => o.Type).Filterable(false).Title("Type");
                                columns.Bound(o => o.ReceiveDate).Title("Date");
                                columns.Bound(o => o.Subject).Title("Subject")
                                .Aggregate(c => c.Count()).
                                GroupHeaderTemplate(@<text>@item.Title: @item.Key (@item.Count)</text>);
                                columns.Bound(o => o.Comments).Title("Comments");
                            }).Groupable(grouping => grouping.Groups(groups =>
                            {
                                groups.Add(c => c.Subject);
                            }))
        )


I want something like this:

@(Html.Telerik().Grid(Model)
                            .Name("Grid1")
                            .Columns(columns =>
                            {
                                columns.Bound(o => o.Type).Filterable(false).Title("Type");
                                columns.Bound(o => o.ReceiveDate).Title("Date");
                                columns.Bound(o => o.Subject).Title("Subject")
                                .Aggregate(c => c.Count()).
                                GroupHeaderTemplate(@<text>@item.Title: @item.Key (@item.Count + Convert.ToInt32(Model.MyCount))</text>);
                                columns.Bound(o => o.Comments).Title("Comments");
                            }).Groupable(grouping => grouping.Groups(groups =>
                            {
                                groups.Add(c => c.Subject);
                            }))
                     )


Is this possible?

Thanks,
Rahul
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Share this question
or