kendoui下拉列表更改事件未触发



我是所有这些的新手,并且对此进行了很多研究,显然没有"得到"。我正在使用c#/。net4.5 mvc4。

我有一个我填充的下拉列表,当我更改下拉值时,我想触发事件。.更改事件我相信(重定向到一个新页面,带有下拉菜的值)

什么也没发生(未触发事件)。
我尝试使用.EVENTS语法作为Kendo代码的一部分,但是我会遇到错误(错误CS1977:不能将lambda表达式用作参数,而无需首先将其施放到委托或表达树类型的情况下,将其用于动态调度的操作)

,我恐怕我不了解过程流以及如何将事件绑定到动作中,尽管阅读了十几个或更多文章。预先感谢您的帮助。

这是我在视图中得到的(index.cshtml)

@model IEnumerable<cfcccDb.Models.matrix>

<form method="post">

@(Html.Kendo().DropDownList()

    .Name("scorematrix")
    .DataTextField("Text")
    .DataValueField("Value")
    .Value(ViewBag.SelectedMatrix)
    .HtmlAttributes(new { style = "width:200px;" })
    .BindTo(@matrixlist)
    )

</form>

<script>

$("#scorematrix").kendoDropDownList({
    change: function (e) {
        var value = this.value();
        alert("value = " + value);
    }
})

</script>

使用MVC包装器,您应该这样做以绑定更改事件:

@(Html.Kendo().DropDownList()
    .Name("scorematrix")
    .DataTextField("Text")
    .DataValueField("Value")
    .Value(ViewBag.SelectedMatrix)
    .HtmlAttributes(new { style = "width:200px;" })
    .BindTo(@matrixlist)
    .Events(e => e.Change("dropdownlist_change")))
<script>
    function dropdownlist_change() {
        //Handle the change event
    }
</script>

如果要绑定JS中的更改事件,则可以这样做:

$("#scorematrix").data("kendoDropDownList").bind("change", function (e) {
    //Handle the change event
});

最新更新