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

[Solved] Problem with related comboboxes and OnItemsRequested Event

1 Answer 134 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Frank Schürer
Top achievements
Rank 1
Frank Schürer asked on 11 Dec 2009, 05:24 PM
Hello,

i'm trying to use related comboboxes.
At first glance everything seems to be fine.

But when i try to scroll to the end of Combo2 the combo flickers shortly and i have now duplicated entries in my Combo2.
The reason is that the "Combo2_ItemsRequested-event" is being called multiple times.

Does anybody have an explanation and a solution for this issue?

Thanks in advance!

here is my code

<telerik:RadComboBox ID="Combo1" Runat="server" Height="22px"  
     Width="340px" MaxHeight="150px" 
     Filter="Contains" 
     ExpandDelay="50" HighlightTemplatedItems="True" 
     OnClientSelectedIndexChanging="LoadCombo2" 
     OnItemsRequested="Combo1_ItemsRequested" 
</telerik:RadComboBox> 

<telerik:RadComboBox ID="Combo2" Runat="server" 
      MaxHeight="150px"  
      OnClientItemsRequested="ItemsLoaded" 
      OnItemsRequested="Combo2_ItemsRequested" 
      style="z-index: 1; position: relative; width: 340px; display:table-cell; top: 0px; height: 21px; left: 0px;"  
      ShowWhileLoading="False"
</telerik:RadComboBox>   

<script type="text/javascript"
    var cboSecond; 
     
    function pageLoad() { 
        cboSecond = $find("Combo2"); 
    } 
 
    function LoadCombo2(combo, eventArqs) { 
        var item = eventArqs.get_item(); 
         
        Combo2.requestItems(item.get_value(), false); 
    } 
 
    function ItemsLoaded(combo, eventArqs) { 
        if (combo.get_items().get_count() > 0) { 
            combo.set_text(combo.get_items().getItem(0).get_text()); 
            combo.get_items().getItem(0).highlight(); 
        } 
    } 
 
</script> 

code on the server side

Protected Sub Combo2_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles Combo2.ItemsRequested 
    If IsNumeric(e.Text) Then 
        Dim id As Long = System.Convert.ToInt32(e.Text) 
        LoadCombo2(id) 
    End If 
End Sub 
 
Private Sub LoadCombo2(ByVal id As Long) 
        Dim sqlda As SqlDataAdapter 
        Dim sqltbl As New DataTable 
        Dim sSQLAffiliates As String 
 
        sSQLAffiliates = GetAffiliateSQL(id) 
 
        sqlda = New SqlDataAdapter(sSQLAffiliates, sqlconn) 
        sqlda.Fill(sqltbl) 
 
        With Me.Combo2 
            .DataTextField = "Affiliate" 
            .DataValueField = "Affiliate_ID" 
            .DataSource = sqltbl 
            .DataBind() 
        End With 
End Sub 

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 Dec 2009, 02:42 PM
Hello Christian Stettner,

This was an issue which we fixed shortly after the Q3 2009 release.

Please see this sticky post for more information.

Greetings,
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.
Tags
ComboBox
Asked by
Frank Schürer
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or