Hello, I have a grid that uses ClientTemplates to display the name associated with an id. When grouping, the id shows instead of the specified name. Is there any way to fix this to group by the selected text from the dropdown created in the ClientTemplate rather than the associated id?
Grid
@(Html.Kendo().Grid<BCGS.Classes.BCGSSite>
()
.Name("sites")
.Columns(columns =>
{
columns.Bound(s => s.SiteName).HeaderHtmlAttributes(new { @style = "font-weight:bold" }); ;
columns.Bound(s => s.DistrictDisplayName).Title("District").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.CountyId).Title("County").ClientTemplate("#=CountyName#").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.Active).ClientTemplate("#= Active? 'Yes' : 'No' # <value ='#= Active #' />").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.SiteCategoryId).Title("Category").ClientTemplate("#=CategoryName#").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.SpecialtyId).Title("Speciality").ClientTemplate("#=SpecialtyName#").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.Address1).Title("Address 1").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.Address2).Title("Address 2").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.City).HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.State).HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Bound(s => s.PostalCode).Title("Zip Code").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(240);
})
.Groupable(g => g.Enabled(true))
.ToolBar(toolbar =>
{
toolbar.Search();
toolbar.Excel();
toolbar.Create();
})
.Excel(excel =>
excel.FileName("Sites.xlsx")
.ProxyURL(Url.Action("Excel_Export_Save", "Grid"))
.AllPages(true))
.Sortable()
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(source => source
.Ajax()
.PageSize(50)
.Events(events => {
events.Error("error_handler");
events.Sync("update");
})
.Model(model =>
{
model.Id(s => s.SiteID);
model.Field(s => s.SiteName).Editable(true);
model.Field(s => s.DistrictDisplayName).Editable(false);
model.Field(s => s.SiteCategoryId).Editable(true);
model.Field(s => s.CountyId).Editable(true);
model.Field(s => s.Active).Editable(true).DefaultValue(true);
model.Field(s => s.Address1).Editable(true);
model.Field(s => s.Address2).Editable(true);
model.Field(s => s.City).Editable(true);
model.Field(s => s.State).Editable(true);
model.Field(s => s.PostalCode).Editable(true);
model.Field(s => s.SpecialtyId).Editable(true);
})
.Create(create => create.Action("SiteEdit", "Admin"))
.Update(update => update.Action("SiteEdit", "Admin"))
.Destroy(destroy => destroy.Action("SiteDelete", "Admin"))
.Read(read => read.Action("SiteGrid", "Admin"))
)
)
EditorTemplate
@model BCGS.Classes.BCGSSite
@(Html.Kendo().DropDownListFor(m => m)
.DataTextField("CountyName")
.DataValueField("CountyId")
.AutoBind(false)
.HtmlAttributes(new { data_value_primitive = "true"})
.OptionLabel(" ")
.BindTo((System.Collections.IEnumerable)ViewData["counties"]))
Thank you,
Megan