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

Combo box loosing selectedItem

5 Answers 162 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Imtiaz
Top achievements
Rank 1
Imtiaz asked on 27 Dec 2008, 08:14 AM
I have multiple comboboxes and a "Add button" next to each combo box. User can type search term, select value and click on "Add button" for next step.

Combo1  - Add Button1
Combo2  - Add Button3
Combo3  - Add Button3



When user types search term in combo1 and selects a value and does not click on Button1 and goto 2nd drop down and search select and click on 2nd add button. Then click on 1st Add button,  Combo1 looses its selected value i.e. get_selectedItem returns null.


Is it possibe for combo1 to retain its value?

Thanks
Imtiaz

 

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Dec 2008, 11:13 AM
Hello Imtiaz ,

RadComboBox is supposed to retain its value, could you please try using get_selectedValue and let us know how it goes?

Greetings,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Imtiaz
Top achievements
Rank 1
answered on 29 Dec 2008, 09:21 PM
comboBox.get_selectedItem() returns null
comboBox.get_selectedValue() return : Object doesn't support this property or method

However get_Value returns the selected Value

Below is the code sample

 var comboBox = $find(("<%=AssetCombo.ClientID%>"));  
        if(comboBox!=null)  
        {  
            //If nothing is selected then do nothing  
            if( comboBox.get_selectedItem()==null)  
            {  
                alert("Please select an asset to continue..");  
                window.event.cancelBubble=true;  
                window.event.returnValue = false;  
                return false;  
            }  
              
            if(comboBox.get_selectedItem().get_attributes().getAttribute("RestrictionEnforment")==1)  
            {  
            ....                  
            } 

Since get_selectedItem is returning null, I am not able to call get_attributes()

Thanks
Imtiaz
0
Yana
Telerik team
answered on 30 Dec 2008, 11:35 AM
Hi Imtiaz,

I am sorry for offering get_selectedValue, RadComboBox really doesn't support such method. You can use the value received from get_value() to find the selected item like this:

var val = comboBox.get_value();  
var item = comboBox.findItemByValue(val);  

Hope this helps.

Best wishes,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Imtiaz
Top achievements
Rank 1
answered on 30 Dec 2008, 10:28 PM

var val = comboBox.get_value();  

returns value
var item = comboBox.findItemByValue(val);

returns 'null'

Looks like it is not maintaining state between postback.
 
Combo1  - Add Button1
Combo2  - Add Button3
Combo3  - Add Button3

I have all three comboboxes in update panel. When user clicks on add on any button ajax postbacks happens, and it is forgetting state of other combo boxes selection.

Thanks
Imtiaz
0
Atanas Korchev
Telerik team
answered on 02 Jan 2009, 02:40 PM
Hello Imtiaz,

We couldn't reproduce the problem locally. Please open a support ticket and send us a running example. Thanks.

Best wishes,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Imtiaz
Top achievements
Rank 1
Answers by
Yana
Telerik team
Imtiaz
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or