I want to be able to expand / collapse grouped column headers in my grid (ASP.NET Core). I have found this example which achieves what I need (https://docs.telerik.com/kendo-ui/knowledge-base/grid-expand-collapse-columns-group-button-click), however the HeaderTemplate() method appears to be unavailable. See my placement below.
I am using the following packages:
KendoUIProfessional, Version="2020.3.915"
Telerik.UI.for.AspNet.Core, Version="2020.3.915"
@(Html.Kendo().Grid<
RegulationViewModel
>
()
.Name("grid")
.Columns(columns =>
{
columns.Select().Width(75).Locked(true);
columns.Group(g => g
.Title("Key information")
.HeaderTemplate("Key info <
button
class
=
'k-button'
style
=
'float: right;'
onclick
=
'onExpColClick(this)'
><
span
class
=
'k-icon k-i-minus'
></
span
></
button
>")
.Columns(i =>
{
i.ForeignKey(p => p.ContinentId, (System.Collections.IEnumerable) ViewData["continents"], "Id", "ContinentName")
.Width(110).Locked(true);
i.ForeignKey(p => p.AreaId, (System.Collections.IEnumerable) ViewData["areas"], "Id", "AreaName")
.Width(150).Title("Area").Locked(true);
})
);
columns.ForeignKey(p => p.CountryStateProvinceId, (System.Collections.IEnumerable)ViewData["countries"], "Id", "CountryStateProvinceName")
.Width(150).Locked(true);
columns.Command(command => command.Destroy()).Width(100);
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
toolbar.Custom().Text("Mark reviewed").Name("review");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.PersistSelection()
.Navigatable()
.Resizable(r => r.Columns(true))
.Reorderable(r => r.Columns(true))
.Sortable()
.Filterable(f => f
.Extra(false)
.Messages(m => m.Info("Show items with:"))
.Operators(operators => operators
.ForString(str => str
.Clear()
.Contains("Contains"))
)
)
.Scrollable(sc => sc.Virtual(true))
.Events(e => e
.Edit("forceDropDown")
.DataBound("onDataBound")
.FilterMenuInit("filterMenuInit")
)
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
model.Field(p => p.ContinentId).DefaultValue((ViewData["defaultContinent"] as ContinentViewModel).Id);
model.Field(p => p.AreaId).DefaultValue((ViewData["defaultArea"] as AreaViewModel).Id);
model.Field(p => p.CountryStateProvinceId).DefaultValue((ViewData["defaultCountry"] as CountryStateProvinceViewModel).Id);
})
.Read(read => read.Action("GetRegulations", "RegulationIndex").Type(HttpVerbs.Get))
.Create(create => create.Action("AddRegulations", "RegulationIndex").Type(HttpVerbs.Post))
.Update(update => update.Action("UpdateRegulations", "RegulationIndex").Type(HttpVerbs.Post))
.Destroy(delete => delete.Action("DeleteRegulations", "RegulationIndex").Type(HttpVerbs.Delete))
))