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

Client side Item Add

3 Answers 82 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Veteran
Iron
Andrew asked on 20 Mar 2009, 06:31 PM

Hi I have followed the example on adding an item to the combobox on the client side.

http://www.telerik.com/help/aspnet-ajax/combo_itemsclientside.html

And it works, but when this happens I loose all other items in the combobox and only the item I haved added is there.

 

Here is my code:

 

 

 

 

 

function

 

AddNewItem(Text, Value)

 

{

 

var combo = $find('<%=rcbPerson.ClientID %>');

 

 

 

var comboItem = new Telerik.Web.UI.RadComboBoxItem();

 

comboItem.set_text(Text);

comboItem.set_value(Value);

 

combo.trackChanges();

combo.get_items().add(comboItem);

comboItem.select();

combo.commitChanges();

comboItem.scrollIntoView();

}


any help would be great

thanks,
Andrew Day

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Mar 2009, 05:50 AM
Hello Andrew Day,

I have used the same code in one of my application to add items from client side and it is working fine and it selects the newly added item after adding. I guess you don't want to select the newly added item in RadComboBox, if so you can remove the line comboItem.select(); and try the same client side code.

Thanks,
Shinu.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 23 Mar 2009, 12:41 PM
I do want to select it, but I also want all the other options to still be there.

for example say I have a combobox with the following Items (a, b, c, d, e) when the page first loads
now I want to add (f) on the clientside and select it this happens ok.
now say I have changed my mind and I want to select (a) instead of the newly added item (f)
all items in the list (a, b, c, d, e) are gone and only the newly addded item of (f) is there.

what happed to (a, b, c, d, e) ? I would expect to see (a, b, c, d, e, f) in the list
0
Paul
Telerik team
answered on 23 Mar 2009, 01:31 PM
Hello Andrew,

We tried to reproduce the reported issue using the latest version of the control, but to no avail. Please find attached a sample web application that shows the proper work of the control. Let us know what's different in your case.

Greetings,
Paul
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Veteran
Iron
Answers by
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Veteran
Iron
Paul
Telerik team
Share this question
or