I have a grid in which I want to bind the generated columns inside the foreach-loop (currently set to "Number") to the dictionary entry of e.Key. The code below works, but I have the problem that I need the sorting functionality of the column menu to sort by the dictionary entry. In the current code I get the Bound "Number" as field to sort by, but I need the dictionary key.
@(Html.Kendo().Grid<
Bauteil
>()
.Name("PartSearchGrid")
.Resizable(resize => resize.Columns(true))
.Sortable()
.ClientDetailTemplateId("detailtemplate")
.PersistSelection(true)
.Selectable(selectable => selectable
.Type(GridSelectionType.Row)
.Mode(GridSelectionMode.Single)
)
.ToolBar(tools =>
{
tools.Custom().Text("<
input
id
=
'partsearchbox'
onkeyup
=
'onSearch()'
placeholder
=
'" + GuiLabel["Label_Search"].Value + "'
/>");
tools.Excel();
tools.Custom().Text("Reset").HtmlAttributes(new { onclick = "resetFilter()" });
})
.Pageable(pageable => pageable
.PageSizes( new[] { 10, 20, 50, 100, 500, 1000 })
.Enabled(true)
.Numeric(true)
)
.Scrollable(s => s.Virtual(GridVirtualizationMode.Rows))
.Columns(columns =>
{
columns.Bound(p => p.Number).Width(100);
columns.Bound(p => p.Name).Width(100);
columns.Bound(p => p._calcNoOfProcesses).Width(100);
foreach (Meta_PlanningProfileEntry e in Model.Part_Profile_Entries)
{
columns.Bound("Number").ClientTemplate("# if (PlanningDataDict[\"" + e.Key + "\"] != null) { #" + "<
p
>#= PlanningDataDict[\"" + e.Key + "\"] #</
p
>" + "# } else { #" + "" + "# } #").Width(100);
}
columns.Bound(p => p.StateString).Width(100);
})
.Excel(excel => excel
.FileName("TP_Parts_Export.xlsx")
.AllPages(true)
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(50)
.ServerOperation(true)
.Model(model =>
{
model.Id(m => m.ID);
})
.Read(r => r.Action("Parts_Read", "Part").Data("getPartFilters"))
)
.ColumnMenu()
)