我有一个kendo组合框,我有一个keno html.checkboxfor控件。我需要根据来自combox的所选文本值启用该复选框启用true或false我使用以下代码但它不适用于我。我需要一些建议。
<tr>
<td>Status Reason</td>
<td>
<div id="options">
@(Html.Kendo().ComboBox()
.Name("StatusReasons")
.Placeholder("Select Status...")
.BindTo(Model.StatusReason)
.DataTextField("statusName")
.DataValueField("statusIndex")
.SelectedIndex(Convert.ToInt32(Model.StatusReasonID) - 1)
.Events(e => e.Select("enableButton"))
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetStatusReasons", "Home");
});
})
.Suggest(true)
.HtmlAttributes(Model.Editable ? new { tabindex = "2" } : (object)new { style = "width:200px", /*disabled = "disabled",*/ tabindex = "2" })
)
</div>
</td>
<td>
Name: @Html.CheckBoxFor(model => model.Name, new { disabled = true, value = "false" })
</td>
<td>
Name 2: @Html.CheckBoxFor(model => model.ReissueDeduction, new { disabled = true, value = "false" })
</td>
</tr>
function enableButton(e)
{
if (e.item) {
var dataItem = this.dataItem(e.item.index());
if (dataItem.statusName == 'Reissue')
{
//make check box enable
} else {
//make check box disable
}
}
}
答案 0 :(得分:0)
使用jquery:
要禁用:
$("#ReissueDeduction").attr("disabled", true);
启用:
$("#ReissueDeduction").removeAttr("disabled");
答案 1 :(得分:0)
这是我认为的答案
启用;
$("#combobox").data("kendoComboBox").enable();
禁用;
$("#combobox").data("kendoComboBox").disable();