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

2 posts, 0 answers
  1. Jon
    Jon avatar
    4 posts
    Member since:
    Jan 2012

    Posted 18 Jul 2012 Link to this post

    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.
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2622 posts

    Posted 19 Jul 2012 Link to this post

    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!
Back to Top