我知道Telerik有一些例子,但我並沒有完全理解它們。你可以在下面看到我的代碼。我究竟做錯了什麼?Terik Grid Dropdown Column
片段格:
.Columns(columns =>
{
columns.Bound(product => product.Id).Hidden();
columns.Bound(product => product.KdNr);
columns.Bound(product => product.Datum).Format("{0:dd.MM.yyyy}");
columns.Bound(product => product.Aktion);
columns.Bound(product => product.Ergebnis).EditorTemplateName("ErgebnisTemplate.cshtml").Title("Ergebnis");
columns.Bound(product => product.Wiedervorlage).Format("{0:dd.MM.yyyy H:mm}");
columns.Bound(product => product.Bemerkung);
columns.Bound(product => product.Erledigt).ClientTemplate(
"<input type='checkbox' disabled='disabled'" +
"# if (Erledigt) { #" +
"checked='checked'" +
"# } #" +
"/>"
);
在這裏你可以看到,列「Ergebnis」,這是第5列綁定到一個自定義模板(EditorTemplateName("ErgebnisTemplate.cshtml")
)。
ErgebnisTemplate.cshtml(位於查看/共享/ EditorTemplates):
@using System.Collections
@model System.Int32
@(Html.Kendo().DropDownList()
.BindTo(new List<SelectListItem>() {
new SelectListItem()
{
Text = "Anrufen",
Value = "A"
},
new SelectListItem()
{
Text = "Verloren",
Value = "V"
}
})
.DataValueField("Value")
.DataTextField("Text")
.Name("Ergebnis")
)
謝謝SOOOO多下的
EditorTemplateName
方法提供的名稱剃刀文件,即簡單的一步做到了!把它作爲答案@AmalDev – Anokrize