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

Insert new item in clientcode fails

1 Answer 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jorgen Vester
Top achievements
Rank 1
Jorgen Vester asked on 06 Oct 2017, 09:30 AM

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();

1 Answer, 1 is accepted

Sort by
0
Jorgen Vester
Top achievements
Rank 1
answered on 06 Oct 2017, 11:59 AM
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());
Tags
ComboBox
Asked by
Jorgen Vester
Top achievements
Rank 1
Answers by
Jorgen Vester
Top achievements
Rank 1
Share this question
or