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

[Javascript] findItemByText - Returning Null

2 Answers 163 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abinash
Top achievements
Rank 1
Abinash asked on 27 Nov 2008, 10:43 AM
Dear All,
Problem Statement - I have a popup window, in which I will search and select one item(internally I have two values). On click of a button I need this text to go to parent page and get inserted into a RADCombobox. If that Item is present, the Item will get selected else a new RADCombobox item needs to be created.
Solution - Once I select one item and click button, I am calling a Javascript function in the parent page as below.

self.opener.AddSelectedOilGrade(selValue,selText);

In the parent page I am trying to find the item existing or not and then selecting this item. Below is the code.

var

combo = $find("<%= cboOilinUse.ClientID %>");

 

 

var item = combo.findItemByText(strText);

 

 

if(item)

 

{item.select();}

 

else

 

{

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

 

comboItem.set_text(strText);

comboItem.set_value(strValue);

comboItem.select();}

I have refered to the example given in the below URL.
http://www.telerik.com/help/aspnet-ajax/combo_clientsidebasics.html 

But this is returning NULL(var comboItem = new Telerik.Web.UI.RadComboBoxItem();).

Please let me know if anything is going wrong.



2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 01 Dec 2008, 08:20 AM
Hello Abinash,

You are trying to select an item which is not added to the Items collection of the combobox.

You need to first add the new item to the combobox and then select it:

combo.trackChanges(); 
var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
comboItem.set_text("New"); 
comboItem.set_value("Value"); 
combo.get_items().add(comboItem); 
combo.commitChanges(); 

More information is available here: RadComboBoxItemCollection object

I hope this helps.

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ramachandran Panduranga
Top achievements
Rank 1
answered on 15 Dec 2008, 09:43 AM
Hi,

I am trying to select an Item and Highlight on a RadCombobox by passing a selected cell value from RadGrid using Clientside script.

I tried using the findItemByText method but ite returning null.

Please Kindly help me with a sample code ASAP.


Many thanks,

Ram
Tags
ComboBox
Asked by
Abinash
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Ramachandran Panduranga
Top achievements
Rank 1
Share this question
or