我有一個網格,其中一列具有帶下拉列表的EditorTemplate。基於列值在kendo ui網格中的列上啓用或禁用EditorTemplateName
columns.Bound(i => i.TypeId).Title("Types").EditorTemplateName("Types").ClientTemplate("#: TypeId != 3 ? Type : '-'#").HtmlAttributes(new { @style = "text-align:center; " }).Width(75);
模板
@(Html.Kendo().DropDownListFor(i => i)
.Name("TypeId")
.DataValueField("Id")
.DataTextField("Type")
.BindTo((IEnumerable)ViewBag.Types)
.OptionLabel("Select Type")
.Value("TypeId")
)
我要做到這一點是當typeid的是3,我不想編輯模板使用什麼。我只想顯示帶有禁用狀態的「 - 」。
我可以使用onedit事件禁用下拉菜單,但我不希望下拉菜單甚至在禁用狀態下顯示。
任何想法將不勝感激。
我所做的禁用模板如下:
function disableOnEdit(e) {
if (e.model.isNew()) {
// Leave it editable if the row is new.
} else {
//Disable the editor for Element in this row.
var select = e.container.find('input[name=TypeId]').data('kendoDropDownList');
if (select != null && select._selectedValue == "3") {
//var text = select.find(".k - input");
//select.dataSource = null;
//select._selectedValue = "-";
//select.editTemplate = null;
//select.innerHTML = "-";
//select._current[0].innerText = "-";
select.enable(false);
}
}
}
我已經嘗試了很多東西,從列刪除下拉列表。我是Kendo UI的新手,請幫助我。
感謝
我已成功地暫時如下週圍做一些工作。通過這種方式,我們編輯時不會顯示下拉列表。 $('#TypeId')。parent()[0] .innerText =「 - 」; select.enable(false); – 2014-09-11 23:45:13