This is a migrated thread and some comments may be shown as answers.

Is there onBind event for DDL?

2 Answers 64 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Aug 2012, 03:04 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
John DeVight
Top achievements
Rank 1
answered on 15 Aug 2012, 01:27 PM
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 :-)
0
John
Top achievements
Rank 1
answered on 17 Aug 2012, 02:11 AM
Thanks John.
It works. Cheers!
Tags
DropDownList
Asked by
John
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
John
Top achievements
Rank 1
Share this question
or