1

I have a input field that I've transformed into a kendoDropDownList. Passed in it's options is a select callback that does some stuff when the user selects a new value.

e.g

$("#MyDropDownList").kendoDropDownList({
    optionLabel: "Choose...",
    dataTextField: "MyTextField",
    dataValueField: "MyValueField",
    dataSource: myDataSource,
    select: function (e) {
        // Do some stuff
  }
});

This bit works fine as long as the user is doing the selecting the value via the gui. The stuff that needs to occur when a value is selected occurs.

The problem occurs if I need to change the selection from code. I have something like this:

// Select dropdown entry by index
$("#MyDropDownList").data("kendoDropDownList").select(0);

When I do this, my select callback isn't called. Is there something I'm doing wrong here? Or should I just take the code that happens on select into it's own function and call that myself when I need it to fire?

4

1 回答 1

1

Yes, calling Kendo UI API methods does not fire events. This is a design decision across the framework (with one exception, the Window widget). You should call the event handler manually after calling the API.

The reasoning behind this is that you are able to select a different item in the select event handler, after validating the new selection. If the widget triggered the select event, this would not be possible (it would cause an infinite trigger-handle loop).

于 2012-11-14T10:17:33.803 回答