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

issue with Related ComboBoxes

3 Answers 38 Views
Window
This is a migrated thread and some comments may be shown as answers.
yao wang
Top achievements
Rank 1
yao wang asked on 11 Aug 2010, 02:55 AM
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

I use the method in above link to implement cascading dropdown list. However I have two issues can not be fixed using the above method.

1. In the last combobox(in above link, it is the city combobox), I set postback = true. However after page postback, the selected value in each combobox is lost. How can I retrieve the selected value for each combobox? Especially for the last combobox?


2. If there is only one selection in combobox, how to disable dropdown function in the combobox . For example, in the above link, if I choose “Asia” in continent combobox, “china” in country combobox,  the “Beijing” will be only one selection in city combobox. How to let “beiJing” display in city combobox directly  and disable its dropdown function?  


From my understanding, the above method is using web service to implement cascading dropdown function, therefore it is stateless even within a same page. I am not sure if issue #1 is related with the stateless feature.  

 

Thanks,

 

Yao

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 16 Aug 2010, 12:04 PM
Hi yao wang,

You can retain the selection in the RadComboBoxes if you set their AllowCustomText properties to true. Otherwise the controls loose their selected values because the Load on Demand Items do not persist across postbacks.

You can achieve the second requirement by handling the client-side ItemsRequested and DropDownOpening events of the target RCB in this way respectively:
function onItemsReqested(sender, eventArqs) {
    sender._preventDropDownOpening = false;
 
    if (sender.get_items().get_count() == 1) {
        // pre-select the first item
        sender.get_items().getItem(0).select();
        sender._preventDropDownOpening = true;
    }
    else if (sender.get_items().get_count() > 1)
        sender.showDropDown();   
}
 
function onDropDownOpening(sender, eventArgs) {
    eventArgs.set_cancel(sender._preventDropDownOpening);
}

I hope this helps.

Best wishes,
Simon
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
yao wang
Top achievements
Rank 1
answered on 17 Aug 2010, 03:44 PM
For the second issue, is it possible to give me the sample code?

thanks a lot.

Yao
0
Simon
Telerik team
answered on 17 Aug 2010, 04:37 PM
Hi yao wang,

The code I provided in my previous post resolves the second issue. Did you test it on your end?

Kind regards,
Simon
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
Tags
Window
Asked by
yao wang
Top achievements
Rank 1
Answers by
Simon
Telerik team
yao wang
Top achievements
Rank 1
Share this question
or