获取KendoUI Combobox id

时间:2015-09-16 13:45:45

标签: javascript kendo-ui kendo-asp.net-mvc

我需要在KendoComboBox中为change事件使用相同的函数。 将Javascript函数与Combobox绑定没有问题。 现在我需要访问更改处理程序中组合框的名称或ID。 我怎样才能做到这一点? 这是我的代码:

@for (int i = 0; i < (ViewData["alertLevels"] as List<AlertLevel>).Count; i++)
{
    AlertLevel lv = (ViewData["alertLevels"] as List<AlertLevel>)[i];
    <div class="col-md-2">
    @Html.HiddenFor(m=>m[i].contactTypeId)
        <strong>@lv.descrizione</strong><br />
        @(Html.Kendo().ComboBoxFor(m=>m[i].contactTypeId)
        .BindTo(ViewData["contactTypes"] as SelectList)
        .Name("cbxContactType["+i+"]")
        .SelectedIndex(0)
        .Events(
        ev=>ev.Change("cbxContactTypeChange")
        )
        )
    </div>   
}

我需要在cbxContactTypeChange函数中访问调用者组合框ID。

1 个答案:

答案 0 :(得分:0)

假设您正在使用组合框更改事件:http://docs.telerik.com/KENDO-UI/api/javascript/ui/combobox#events-change

你可以得到这样的ID:

mongo
  

<强> DEMO