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

SelectedValue is empty - RadComboBox and EnableLoadOnDemand=false

6 Answers 502 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 04 Jun 2009, 06:41 AM

Hello,

i use the RadComboBox with LoadOnDemand. In my Javascript code i'm calling comboBox.requestItems(...) to fill the RadComboBox. The EnableLoadOnDemand property ist set to false (there is no option for true in my workflow). After a postback, the SelectedValue is always empty. If i set EnableLoadOnDemand to true, the SelectedValue will be set (but this is no option for me). Is there a solution for this problem?

Best Regards

6 Answers, 1 is accepted

Sort by
0
cs137
Top achievements
Rank 1
answered on 10 Jun 2010, 11:24 AM
Hello,

I have the same issue. On page load i add to combobox some default item so user will see some already selected value. Then I call items loading via WS manually in JS and do not use EnableLoadOnDemand option in order to leave combobox in ready only mode. But on postback RadCombobox control doesn't handle data posted  from client side (received data is correct - according to user selection) and leaves item was added on page load selected (only control Text property is changed correctly).

ASPX:
   <telerik:RadScriptBlock runat="server"
        <script type="text/javascript"
            function OnCountriesDropdownOpened<%= ClientID %>(sender, eventArgs) 
            { 
                $find('<%= ddlClientCountry.ClientID %>').requestItems('', false); 
            } 
 
        </script> 
    </telerik:RadScriptBlock> 
     
    <telerik:radcombobox id="ddlClientCountry"   
            Runat="server"   
            CollapseDelay="0"   
            ExpandDelay="0"  
            ShowDropDownOnTextboxClick="true"
            Height="350" >  
            <WebServiceSettings Method="GetCountries" Path="../../WebServices/PhoneNumberService.asmx" />  
        <expandanimation duration="0" type="None"></expandanimation>  
        <collapseanimation duration="0" type="None"></collapseanimation>  
           
    </telerik:radcombobox>   

C#:
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
            ddlClientCountry.OnClientDropDownOpened = "OnCountriesDropdownOpened" + ClientID; 
             
            ... 
        }    

0
Kyle Butler
Top achievements
Rank 2
answered on 11 Jun 2010, 07:58 PM
Dominic, is your MarkFirstMatch property set to true? If so, set it to false. This is a bug in the control.
0
Kyle Butler
Top achievements
Rank 2
answered on 11 Jun 2010, 08:01 PM
Dominic, is your MarkFirstMatch property set to true? If so, set it to false. This is a bug in the control.
0
Kalina
Telerik team
answered on 14 Jun 2010, 04:40 PM
Hello Stepan Melnichuk,

Let me suggest you set the AllowCustomText property of the radComboBoxStateProvince  to "true".
Then if you prefer to restrict user typing in the RadComboBox input  - handle the OnClientLoad event of the radComboBoxStateProvince as shown below:

function OnClientLoadHandler(sender)
{
    sender.get_inputDomElement().readOnly = "readonly";
}

If the issue persists - could you please paste here the full code of your implementation?

All the best,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
cs137
Top achievements
Rank 1
answered on 15 Jun 2010, 07:10 AM
I fixed it by handling OnClientSelectedIndexChanged and doing the following:

       function Client_indexChanged(sender, eventArgs) 
        { 
            //checking for avoid cycle 
            if(sender.get_items().get_count()>1) 
            { 
                var item = eventArgs.get_item(); 
                var value = item.get_value(); 
                var text = item.get_text(); 
                     
                sender.clearItems(); 
                sender.clearSelection(); 
 
                var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
                comboItem.set_text(text); 
                comboItem.set_value(value); 
                     
                sender.trackChanges(); 
                sender.get_items().add(comboItem); 
                comboItem.select(); 
                sender.commitChanges();   
            } 

0
Clarence
Top achievements
Rank 1
answered on 08 Jul 2010, 06:29 PM
Stephan, thanks for the code.  I've modified it so that the value can be set when only one item is selected.

function OnClientSelectedIndexChanged(sender, eventArgs) {
    var item = eventArgs.get_item();
    var value = item.get_value();
    var text = item.get_text();
    var itemCount = sender.get_items().get_count();
    if (itemCount > 1) {
        sender.clearItems();
        sender.clearSelection();
        var comboItem = new Telerik.Web.UI.RadComboBoxItem();
        comboItem.set_text(text);
        comboItem.set_value(value);
        sender.trackChanges();
        sender.get_items().add(comboItem);
        comboItem.select();
        sender.commitChanges();
    }
    if (itemCount = 1) {
        sender.trackChanges();
        sender.set_text(text);
        sender.set_value(value);
        sender.commitChanges();
    }
}
Tags
ComboBox
Asked by
Dominic
Top achievements
Rank 1
Answers by
cs137
Top achievements
Rank 1
Kyle Butler
Top achievements
Rank 2
Kalina
Telerik team
Clarence
Top achievements
Rank 1
Share this question
or