I'm using the recommended approach to using Kendo Widgets in a grid Column ClientTemplate from here: https://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-do-i-use-a-kendo-ui-widget-inside-a-grid-client-column-template
PROBLEM: The DropDownList I am attempting to use only appears for the first row - all other rows simply show a textbox. In addition, when I attempt to select an item in the DropDownList, I get a select menu, and a textbox above it with the value "0."
VIEW:
@(Html.Kendo().Grid(Model.ProjectViewModels) .Name("projectsGrid") .ToolBar(tools => tools.Create().Text("Add Project")) .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom)) .Columns(columns => { columns.Bound(p => p.Id).Hidden(); columns.Bound(a => a.ProjectCategoryTypeId) .Title("High Level Category") .ClientTemplate( Html.Kendo().DropDownList() .Name("ProjectCategoryTypeId") .DataValueField("Value") .DataTextField("Text") .BindTo(Model.ProjectCategoryTypes) .HtmlAttributes(new { @class = "templateCell" }) .ToClientTemplate() .ToHtmlString()) .Sortable(true); columns.Command(command => command.Destroy()).Width(100); }) .Events(ev => ev.DataBound("initTemplates")) .DataSource(dataSource => dataSource .Ajax() //.Events(e => e.Change("initTemplates")) .Model(model => { model.Id(p => p.Id); model.Field(p => p.Id).Editable(false); }) .ServerOperation(false) ))
SCRIPT:
// this approach works, but only for the first row...function initTemplates(e) { $(".templateCell").each(function () { eval($(this).children("script").last().html()); });}