triggering combo box events programmatically

4 posts, 0 answers
  1. Stephen
    Stephen avatar
    11 posts
    Member since:
    Mar 2013

    Posted 23 Jun 2013 Link to this post

    I have a combo box set up to cascade to another combo box. This works.  I have mapped both a change event and a select event in the "parent" - - both of which also work. I am planning to observer the state of the "parent"  knockout via the knockout-kendo plugin.  I expect this to work.

    BUT - I need to be able to trigger the cascade programmatically, as well.  That is, I need to programmatically change the selected index of the "parent".  To test this in advance of mapping it in knockout,  I have a test button that successfully changes the selected item in the "parent".  So, this works.

    Here is problem: neither the change event nor a select event are triggered in response to the following (which is in the test button click handler):
    var cbx = $("select").data("kendoComboBox")
    cbx.select(2);
    That is, the combo box changes state but kendo is not triggering either of  the events.

    I have tried this in various fiddles (modifying a similar situation) and it does not work there either.

    This is quite important to us, so please let me know if this is not supported.

    Thanks

    S



  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 24 Jun 2013 Link to this post

    Hello,

    Please try with below code snippet to trigger event.

    $("select").data("kendoComboBox").value(null);
    $("select").data("kendoComboBox").trigger("change");


    Thanks,
    Jayesh Goyani
  3. Kendo UI is VS 2017 Ready
  4. Stephen
    Stephen avatar
    11 posts
    Member since:
    Mar 2013

    Posted 24 Jun 2013 Link to this post

    Hello Jayesh

    Thanks for the reply and this indeed works, though I am exactly sure why. 

    As a input to telerik, this is not in any documentation I can find - nor is the trigger function immediately obvious in the any of the fn objects under the kendo namespace.  I guess the answer is that since this is clearly a (modified) jQ event object, it should inherit the jQ trigger function - which would map tot the cached jQ events. Is that correct in your view?

    Again, thanks for assist.

    S
  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 26 Jun 2013 Link to this post

    Hello guys,

    @Stephen:
    Actually the trigger method is documented - it is a common method for the kendo.ui.Widget class and is inherited from kendo.Observable.


    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready