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

[Solved] RadComboBox - To Interact Related Combo Boxes Without Postback

7 Answers 175 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Gideon
Top achievements
Rank 1
Gideon asked on 07 Oct 2009, 02:40 AM
Hi,

Refer to the example of Related ComboBoxes (3 combo boxes: Continent, Country, City), is it possible to interact between combo boxes without postback? (without using the OnItemRequested or OnClientItemRequested events)

And is it possible to call WCF inside the javascript and fills values to the combo box directly?

Thank You.

7 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 12 Oct 2009, 05:44 AM
Hello Omar Suria,

If you bind the second and third combos to WCF service and not to ItemsRequested server event then calling the requestItems() javascript method will fire the proper WCF operation contract and the items will be loaded.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
tomekm
Top achievements
Rank 1
answered on 11 Nov 2009, 01:17 PM

   
            var continentCombo;    
            var countryCombo;    
            var cityCombo;    
    
            function pageLoad() {    
                // initialize the global variables    
                // in this event all client objects     
                // are already created and initialized    
                continentCombo = $find("<%= RadComboBox1.ClientID %>");    
                countryCombo = $find("<%= RadComboBox2.ClientID %>");    
                cityCombo = $find("<%= RadComboBox3.ClientID %>");    
            }    
    
            function requestCountry(sender, e) {    
                var context = e.get_context();    
                context["CountryId"] = continentCombo.get_selectedItem().get_value();    
            }    
    
            function requestCity(sender, e) {    
                var context = e.get_context();    
                context["CityId"] = countryCombo.get_selectedItem().get_value();    
            }    
    
                
    
            function ItemsLoaded(combo, eventArqs) {    
                if (combo.get_items().get_count() > 0) {    
                    // pre-select the first item    
                    combo.set_text(combo.get_items().getItem(0).get_text());    
                    combo.get_items().getItem(0).highlight();    
                }    
            }    
    
            function ContinentChanged(combo, eventArqs) {    
                countryCombo.clearItems();    
                countryCombo.clearSelection();       
            }    
    
            function CountryChanged(combo, eventArqs) {    
                cityCombo.clearItems();    
                cityCombo.clearSelection();    
 
            }   
 
 
 
 
 
 
<telerik:RadComboBox ID="RadComboBox1" DataSourceID="LinqDataSource1" DataTextField="Name"  
 OnClientSelectedIndexChanged="ContinentChanged" DataValueField="Id"  
 runat="server">  
 </telerik:RadComboBox>  
 <telerik:RadComboBox ID="RadComboBox2" runat="server" OnClientItemsRequesting="requestCountry"  
  OnClientSelectedIndexChanged="CountryChanged" EnableLoadOnDemand="true">  
 <WebServiceSettings Path="Code/DictionariesService.svc" Method="GetCountryItems" />  
 </telerik:RadComboBox>  
 <telerik:RadComboBox ID="RadComboBox3" runat="server" OnClientItemsRequesting="requestCity"  
 EnableItemCaching="false" EnableLoadOnDemand="true">  
 <WebServiceSettings Path="Code/DictionariesService.svc" Method="GetCityItems" />  
 </telerik:RadComboBox> 
 

0
tomekm
Top achievements
Rank 1
answered on 12 Nov 2009, 10:45 AM

Above is my solution to related comboboxes databound with WCF service.

Its only flaw is that user must select item with mouse or arrows and not by typing first letters because then combobox requests items again and they are duplicated.

Anyone can come up with idea how to improve it?

0
Veselin Vasilev
Telerik team
answered on 16 Nov 2009, 02:54 PM
Hi Rychu,

Your code seems fine.

Are you referring to this issue?
FIX: Items loaded on demand can be added multiple times on scroll (Q3 2009 issue)


Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
tomekm
Top achievements
Rank 1
answered on 24 Nov 2009, 08:37 AM
Yes.
0
Simon
Telerik team
answered on 24 Nov 2009, 09:17 AM
Hello Rychu,

Then please apply one of the workarounds suggested in the forum post to resolve the issue.

All the best,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
tomekm
Top achievements
Rank 1
answered on 24 Nov 2009, 09:33 AM
Thank you, it resolved issue.
Tags
ComboBox
Asked by
Gideon
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
tomekm
Top achievements
Rank 1
Simon
Telerik team
Share this question
or