0
我希望允許下拉列表顯示以前選擇的值,但現在已從下拉列表源中刪除。而不是顯示空白。下拉列表位於網格列中。如果選中的值不在源中,DropDownList將顯示空白值
網:
...
columns.ForeignKey(p => p.CurrentCategory, @Model.LookupCategory, "CategoryName", "CategoryName").Width(160);
...
模板編輯器
@using System.Collections
@(
Html.Kendo().DropDownListFor(m => m)
.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
.ValuePrimitive(true)
.AutoWidth(true)
)
因此,在更詳細的解釋:該CurrentCategory列是文本列(而不是ID列),並且用戶可以從LookupCategory中找到的項目列表中進行選擇。但是,如果從LookupCategory中刪除某個項目,則應該在用戶已經爲CurrentCategory選擇該值的情況下顯示該值。
當前,如果一行包含不在LookupCategory列表中的CurrentCategory值,它將顯示爲空白。
也許我必須使用組合框呢?
謝謝,這個工程。有沒有辦法避免使用ViewData並直接從模型填充? – Reafidy
我不這麼認爲 –