Updating DropDownList Items Text

1 posts, 0 answers
  1. JQuery
    JQuery avatar
    1 posts
    Member since:
    Mar 2012

    Posted 21 Mar 2012 Link to this post

    Hello,

    I'm evaluating KendoUI for a project. One of the needs is to be able to dynamically update the text of the items in a DropDownList. With traditional HTML / JQuery, I can do the following:

    <select id="myOptions">
      <option value="0">Some Text</option>
      <option value="1">Some Other Text</option>
      <option value="2">Third Option Text</option>           
    </select>
     
    ...
     
    $("#myOptions option[value='0']").text(getUpdatedText(0));
    $("#myOptions option[value='1']").text(getUpdatedText(1));
    $("#myOptions option[value='2']").text(getUpdatedText(2));

    This works exactly as desired. I've tried something similar in Kendo, however, I haven't had any success. My most recent attempt looks like this:

    <select id="myOptions">
      <option value="0">Some Text</option>
      <option value="1">Some Other Text</option>
      <option value="2">Third Option Text</option>          
    </select>
      
    ...
      
    $("#myOptions").kendoDropDownList();
    $("#myOptions option[value='0']").text(getUpdatedText(0));
    $("#myOptions option[value='1']").text(getUpdatedText(1));
    $("#myOptions option[value='2']").text(getUpdatedText(2));
    $("#myOptions").data("kendoDropDownList").refresh();

    Unfortunately, the text of the options never updates. The reason I need to do this is because I need to update the text of the options on a regular interval. Can someone please tell me what I'm doing wrong?

    Thank you!
Back to Top