How Can I make to select first item?

1 Answer 8117 Views
DropDownList
Shirley
Top achievements
Rank 1
Shirley asked on 17 Sep 2013, 06:58 AM
I want to make select first item on dropdownlist.


so, after item has bounded, I tried this.

$("#CATEGORY_CODE").data("kendoDropDownList").select(0);

and I tried to check the value,
alert($#CATEGORY_CODE").val());
alert($("#CATEGORY_CODE").data("kendoDropDownList").value());

but I could see "null" and "undefined" messages.

What's wrong? anyone please let me know.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 17 Sep 2013, 12:49 PM
Hello Shirley,

To select an item by its index initially you could use the index configuration property of the widget. If you would like to select through the API method, please make sure that the DropDownList data is already retrieved when the select code is executed.

In your case, I believe that the code fails because the asynchronous Ajax request is not yet finished. Please try to execute the code at the dataBound event handler.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Shirley
Top achievements
Rank 1
commented on 20 Sep 2013, 06:05 AM

Thanks.

but I tried that after item has been bind.

this code has executed from a event  after page has loaded completely.

and this problem has occur only in Explorer 9.
Alexander Valchev
Telerik team
commented on 20 Sep 2013, 08:41 AM

Hello Shirley,

I created a small example:
Please let me know what I am missing.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Shirley
Top achievements
Rank 1
commented on 23 Sep 2013, 01:37 AM

Thanks. I checked it.
working well.

Tags
DropDownList
Asked by
Shirley
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or