Insert new item in clientcode fails

2 posts, 0 answers
  1. Jorgen Vester
    Jorgen Vester avatar
    3 posts
    Member since:
    Jun 2017

    Posted 06 Oct 2017 Link to this post

    Hey

    I show a list of values to the user. If the user types a value that's not in the list, it must be added to the list.

    I try to do this in OnClientBlur with the following code. I start with insert at index = 0 as first step.

    Next step is to add at the end of the list, but the code fails in the first step. I have attached a screendump of the error.

    var items = sender.get_items();
    alert('items.get_count():' + items.get_count());
    sender.trackChanges();
    var comboItem = new Telerik.Web.UI.RadComboBoxItem();
    comboItem.set_text(value);
    comboItem.set_value(value);
    items.insert(0, comboItem);
    sender.commitChanges();

  2. Jorgen Vester
    Jorgen Vester avatar
    3 posts
    Member since:
    Jun 2017

    Posted 06 Oct 2017 in reply to Jorgen Vester Link to this post

    I found the error myself. The values are integers, and they are shown as text also. 
    The error is caused by this and disappeared when I changed this: comboItem.set_text(value); ->
    comboItem.set_text(value.toString());
Back to Top