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

How do I bind existing DropDownList to client-side data?

1 Answer 373 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 18 Jul 2012, 08:50 PM
I have the data I want to bind to already on the client. How can I bind to it?

Trying this:

var dropdownList = $('#list').data("kendoDropDownList");
dropdownList.dataSource.data([{ text: "i1", value: "1" }, { text: "i2", value: "2" }, { text: "i3", value: "3"}]);


Does not work. Please help.

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 19 Jul 2012, 12:27 PM
Hello Jon,

To achieve this you could create a new DataSource instance and bind the DropDown widget to it. For example: 
var myData= [
   { text: "i1", value: "1" },
   { text: "i2", value: "2" },
   { text: "i3", value: "3"}
];
 
 var dataSource = new kendo.data.DataSource({
   data: myData
});
 
$("#list").kendoDropDownList({
   dataSource: dataSource 
   //....
});

More detailed information about the DataSource component and its configuration options is available at this topic from our online documentation.

 

Greetings,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Jon
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or