Is there onBind event for DDL?

3 posts, 1 answers
  1. John
    John avatar
    15 posts
    Member since:
    Jul 2011

    Posted 14 Aug 2012 Link to this post

    If I have below js code for a DDL, which means defaultly select 1st one after rebind DDL:

    DDLDataSource.read();
    DDL.select(0);

    It will select 1st one of previous datasouce.
    I guess when running DDL.select(0), DDL rebind is not fully complete.

    so questions:
    1. why DDL hasn't a OnBind event so that we can walk around this situation?
  2. Answer
    John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 15 Aug 2012 Link to this post

    Hi John,

    I did some digging around the Kendo UI source code and it turns out that there is a dataBound event.

    If I have the following HTML:
    <input id="customers"></input>

    And I initialize the dropdownlist like this:
    var _customers = $("#customers").kendoDropDownList({
        index: 0,
        placeholder: "Select Customer",
        dataTextField: "CompanyName",
        dataValueField: "CustomerID",
        dataSource: {
            type: "odata",
            serverFiltering: true,
            serverPaging: true,
            pageSize: 20,
            transport: {
            }
        }
    }).data("kendoDropDownList");

    I can bind to the dataBound event like this and select the desired item:
    _customers.bind("dataBound", function() {
        _customers.select(5);
    });

    I've put together an example that you can look at on jsfiddle at: jsFiddle: DropDownList DataBound Event

    Hope that helps...

    Regards,

    John DeVight

    P.S. - If I answered your question, please mark my response as the answer :-)
  3. Kendo UI is VS 2017 Ready
  4. John
    John avatar
    15 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2012 Link to this post

    Thanks John.
    It works. Cheers!
Back to Top