Rohil Patel
Rohil Patel

Reputation: 265

make html.checkboxfor enable true false

I have a kendo combobox and i have a keno html.checkboxfor control. I need to make that checkbox enable true or false base on the selected text value from the combox i am using the following code but its not working for me. I need some suggestions.

<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
        }
    }
}

Upvotes: 0

Views: 1014

Answers (2)

Here is the answer I think

Enable;

$("#combobox").data("kendoComboBox").enable();

Disable;

$("#combobox").data("kendoComboBox").disable();

Refered from telekikcombobox

Upvotes: 0

sleeyuen
sleeyuen

Reputation: 941

Using jquery:

To disable:

$("#ReissueDeduction").attr("disabled", true);

To enable:

$("#ReissueDeduction").removeAttr("disabled");

Upvotes: 1

Related Questions