I've created a DropDownList EditorTemplate for grid inline editing successfully. Now I would like to reuse this template in multiple columns (same grid), and/or in different views with different grids.
What I figured out so far is if I omit the 'Name' for the dropdownlist in the template then the template automatically binds to that column what refers to it in the grid (using .EditorTemplateName(...)). However there are other things what should be parameterized (explicit or implicit) firstly the dropdown datasource.
Q: Having many dropdown in one grid, how to parameterize the dropdown datasource to prevent copy and paste the DropDownListTemplate.cshtml zillon times?
Q: Generally how can I parameter this template when using in multiple columns, and multiple views?
The view:
@(Html.Kendo().Grid<Enumeration>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Locale).Width(200)
.EditorTemplateName("DropDownListTemplate");
// columns.Bound(e => e.OtherColumn).Width(200)
// .EditorTemplateName("DropDownListTemplate", ???);
...and the template called DropDownListTemplate.cshtml and placed in /Views/Shared/EditorTemplates
@model string
@(Html.Kendo()
.DropDownListFor(m => m)
.BindTo(ViewBag.LocaleDropDownListDataSource) // <- Having many dropdown in one grid, how to parameterize this, without copy and paste the DropDownListTemplate.cshtml zillon times?
//.OptionLabel("Select Locale")
.DataValueField("Locale")
.DataTextField("Value")
//.Name("Locale") // Omitting this binds the template automatically to the referring column in the grid. Using a custom .Name, what is not a column name in the grid ruins the working
)