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

combobox problem

5 Answers 87 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 11 Jul 2009, 04:26 PM
I have 3 combo boxes on a page, combo1, combo2 & combo3

the contents of combo2 are filtered by the selected value in combo1
the contents of combo3 are filtered by the selected value in combo2

I need to obtain the currently selected value in combo1 as an additional filter value for combo box 3 and was given an example involving a context filter.  This example is stuck in an endless loop.  heres the code for the combo

<telerik:RadComboBox ID="RadComboBoxCategories" Runat="server" Width="100%" OnClientItemsRequested="ItemsLoaded" OnClientItemsRequesting="ClientItemsRequesting" 
                        onitemsrequested="RadComboBoxCategories_ItemsRequested" Skin="Default" EnableLoadOnDemand="true">  
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </telerik:RadComboBox> 





<

 

telerik:RadComboBox ID="RadComboBoxType" Runat="server" OnClientSelectedIndexChanging="LoadGenres"

 

 

onitemsrequested="RadComboBoxType_ItemsRequested" Skin="Default"

 

 

Width="100%" EnableLoadOnDemand="true" AutoPostBack="False"

 

 

onselectedindexchanged="RadComboBoxType_SelectedIndexChanged">

 

 

<CollapseAnimation Duration="200" Type="OutQuint" />

 

 

</telerik:RadComboBox>

 



heres the javascript function


function ClientItemsRequesting(sender, eventArgs) {  
                var context = eventArgs.get_context();  
                var typeCombo = $find("<%= RadComboBoxType.ClientID %>");  
                context["FilterString"] = typeCombo.get_text();  
            } 
  and the c#


protected void RadComboBoxCategories_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)  
        {  
            string temp = e.Context["FilterString"].ToString();  
            LoadCategories(e.Text, temp);  
        } 
  the Itemsrequested event is being fired in an endless loop !

can you help ?  The LoadCategories method needs the value currently selected in the RadComboBoxType as part of the filter

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 13 Jul 2009, 08:18 AM
Hello mww,

Could you please paste here the rest of the relevant JavaScript code as the provided so far does not provide enough information?

Regards,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Jose
Top achievements
Rank 2
answered on 14 Jul 2009, 09:04 PM
Hi mwm.

I would suggest you check this sample from the demos:

http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

it has everything you need for your scenario.

Best regards.
Jose Guay



0
mww
Top achievements
Rank 1
answered on 18 Jul 2009, 09:05 AM
unfortunately that example doesnt work in my case, I need to obtain 2 values, one from the first combo box, the other from the second, these are used to filter the contents of the third combo box.

0
mww
Top achievements
Rank 1
answered on 18 Jul 2009, 09:07 AM
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
   
        <script type="text/javascript">  
 
            function LoadGenres(combo, eventarqs) {  
                //debugger;  
 
                  
                  
                  
                var categoriesCombo = $find("<%= RadComboBoxCategories.ClientID %>");  
                var genresCombo = $find("<%= RadComboBoxArtistGenre.ClientID %>");  
 
                var item = eventarqs.get_item();  
 
                genresCombo.set_text("Loading...");  
                categoriesCombo.clearSelection();  
 
                if (item.get_index() > 0) {  
                    genresCombo.requestItems(item.get_value(), false);  
                }  
                else {  
                    genresCombo.set_text(" ");  
                    genresCombo.clearItems();  
 
                    categoriesCombo.set_text(" ");  
                    categoriesCombo.clearItems();  
                }  
            }  
 
            function LoadCategories(combo, eventarqs) {  
 
                  
                  
                var categoriesCombo = $find("<%= RadComboBoxCategories.ClientID %>");  
                var genresCombo = $find("<%= RadComboBoxArtistGenre.ClientID %>");  
                var item = eventarqs.get_item();  
 
                categoriesCombo.set_text("Loading...");  
                categoriesCombo.requestItems(item.get_value(), false);  
            }  
 
            function ItemsLoaded(combo, eventarqs) {  
                  
                var categoriesCombo = $find("<%= RadComboBoxCategories.ClientID %>");  
                var genresCombo = $find("<%= RadComboBoxArtistGenre.ClientID %>");  
 
                if (combo.get_items().get_count() > 0) {  
                    combo.set_text(combo.get_items().getItem(0).get_text());  
                    combo.get_items().getItem(0).highlight();  
                }  
                combo.showDropDown();  
            }  
 
            function ClientItemsRequesting(sender, eventArgs) {  
                var context = eventArgs.get_context();  
                var typeCombo = $find("<%= RadComboBoxType.ClientID %>");  
                context["FilterString"] = typeCombo.get_text();  
            }  
                 
        </script>   
   
    </telerik:RadCodeBlock> 
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
            <ajaxsettings> 
                <telerik:AjaxSetting AjaxControlID="RadComboBoxArtistType">  
                    <updatedcontrols> 
                        <telerik:AjaxUpdatedControl ControlID="RadComboBoxArtistType" /> 
                    </updatedcontrols> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadComboBoxArtistGenre">  
                    <updatedcontrols> 
                        <telerik:AjaxUpdatedControl ControlID="RadComboBoxArtistGenre" /> 
                    </updatedcontrols> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadComboBoxArtistCategory">  
                    <updatedcontrols> 
                        <telerik:AjaxUpdatedControl ControlID="RadComboBoxArtistCategory" /> 
                    </updatedcontrols> 
                </telerik:AjaxSetting> 
            </ajaxsettings> 
        </telerik:RadAjaxManagerProxy>   
 
 
 
 
<div id="Advance-search_area">  
 <h5>Advanced Search</h5> 
 
      <div id="left">  
      <div class="left_input1">  
       <telerik:RadComboBox ID="RadComboBoxType" Runat="server" OnClientSelectedIndexChanging="LoadGenres" 
                         Skin="Default"   
              Width="100%"   EnableLoadOnDemand="true" AutoPostBack="False"   
              onselectedindexchanged="RadComboBoxType_SelectedIndexChanged">  
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
             </telerik:RadComboBox> 
         </div> 
           
      <div class="left_input2">  
      <telerik:RadComboBox ID="RadComboBoxCategories" Runat="server" Width="100%" OnClientItemsRequested="ItemsLoaded" 

OnClientItemsRequesting

 

="ClientItemsRequesting"

 

  
                        onitemsrequested="RadComboBoxCategories_ItemsRequested" Skin="Default" EnableLoadOnDemand="true">  
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </telerik:RadComboBox> 
         
         </div> 
           
           
       <div class="left_input1">  
          <telerik:RadComboBox ID="RadComboBoxMaxFee" runat="server"   
           Skin="Default" EnableScreenBoundaryDetection="False" Height="200px" Width="100%">  
         <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            </telerik:RadComboBox>   
          </div>    
               
        
           
           
          
      </div> 
 
     
 
    <div id="right">  
      
      
     <div class="right_input1">  
        <telerik:RadComboBox ID="RadComboBoxArtistGenre" Runat="server" OnClientSelectedIndexChanging="LoadCategories"   
                    OnClientItemsRequested="ItemsLoaded" Skin="Default" 
                    Width="100%" onitemsrequested="RadComboBoxArtistGenre_ItemsRequested" EnableLoadOnDemand="true">  
                    <CollapseAnimation Duration="200" Type="OutQuint" /> 
             </telerik:RadComboBox> 
     </div> 
         
         
          <div class="right_input2">        
            <telerik:RadComboBox ID="RadComboBoxLocation" runat="server" 
               Skin="Default" EnableScreenBoundaryDetection="True" Width="100%" > 
              <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
           </telerik:RadComboBox> 
            </div> 
              
 
       
       <div class="clearfloats"></div> 
   <div class="button">   
    <asp:ImageButton ID="ImageButtonSearch" runat="server" CssClass="search-button" ImageUrl="~/images/buttons/button-search.gif" onclick="ImageButtonSearch_Click" />      
    </div>   
        
         </div>   
       </div>   
           
  <!-- end of search goes here --> 
0
Simon
Telerik team
answered on 22 Jul 2009, 08:29 AM
Hi mww,

Thank you for providing the code.

I assembled a simple page with your code and could not recreate the loop you are referring to. Each ItemsRequested event handler fired once per ComboBox when a request was initiated client-side.

In order to help you resolve the issue, I will need to first reproduce it.

Please open a formal support ticket and send us a working version of your page, exhibiting the issue - we will inspect it and will provide either a workaround or a concrete solution.

All the best,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
ComboBox
Asked by
mww
Top achievements
Rank 1
Answers by
Simon
Telerik team
Jose
Top achievements
Rank 2
mww
Top achievements
Rank 1
Share this question
or