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

[Solved] GroupHeaderTemplate on hidden columns

1 Answer 75 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.
iConect Developer - Mike
Top achievements
Rank 1
iConect Developer - Mike asked on 11 Nov 2011, 08:21 PM
For some reason if I hide the column that I'm using for grouping the GroupHeaderTemplate of that column gets ignored. Is there anyway to get it to be used and the column to be still hidden?

@{
  Html.Telerik().Grid(Model.Items)
  .Name("gridSummary")
  .Columns(columns =>
  {
    columns.Bound(o => o.Type)
      .Width(175)
      .FooterTemplate(@<text>Project Total</text>)
      .GroupFooterTemplate(@<text>Subtotal</text>);
    columns.Bound(o => o.TopLevel)
      .HeaderHtmlAttributes(new { style = "text-align:center;" })
      .FooterHtmlAttributes(new { style = "text-align:center;" })
      .HtmlAttributes(new { style = "text-align:center;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:n0}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>);
    columns.Bound(o => o.Attached)
      .HeaderHtmlAttributes(new { style = "text-align:center;" })
      .FooterHtmlAttributes(new { style = "text-align:center;" })
      .HtmlAttributes(new { style = "text-align:center;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:n0}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>);
    columns.Bound(o => o.Embedded)
      .HeaderHtmlAttributes(new { style = "text-align:center;" })
      .FooterHtmlAttributes(new { style = "text-align:center;" })
      .HtmlAttributes(new { style = "text-align:center;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:n0}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>);
    columns.Bound(o => o.Count)
      .HeaderHtmlAttributes(new { style = "text-align:center;" })
      .FooterHtmlAttributes(new { style = "text-align:center;" })
      .HtmlAttributes(new { style = "text-align:center;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:n0}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>);
    columns.Bound(o => o.Days)
      .HeaderHtmlAttributes(new { style = "text-align:center;" })
      .FooterHtmlAttributes(new { style = "text-align:center;" })
      .HtmlAttributes(new { style = "text-align:center;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:n0}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:n0}")</text>);
    columns.Bound(o => o.Cost)
      .HeaderHtmlAttributes(new { style = "text-align:right;" })
      .FooterHtmlAttributes(new { style = "text-align:right;" })
      .HtmlAttributes(new { style = "text-align:right;" })
      .Aggregate(aggreages => aggreages.Sum())
      .Format("{0:c}")
      .FooterTemplate(@<text>@item.Sum.Format("{0:c}")</text>)
      .GroupFooterTemplate(@<text>@item.Sum.Format("{0:c}")</text>);
   
    columns.Bound(o => o.Group)
      //.Aggregate(aggregates => aggregates.Sum())
      .GroupHeaderTemplate(@<text>@item.Key</text>)
      //.GroupFooterTemplate(@<text>Subtotal</text>)
      .Visible(false);
  })
  .Groupable(settings => settings.Groups(groups =>
  {
    groups.Add(o => o.Group);
  }).Visible(false))
  .Scrollable(scrolling => scrolling.Height(450).Enabled(true))
  .Sortable(sorting => sorting.Enabled(false))
  .Pageable(paging => paging.Enabled(false))
  .Footer(true)
  .Render();
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 14 Nov 2011, 09:28 AM
Hi Keith,

In this case Hidden should be used instead of Visible. Therefore, could you please give it a try.

All the best,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
iConect Developer - Mike
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or