how to capture event when value changes

5 posts, 0 answers
  1. Bort
    Bort avatar
    10 posts
    Member since:
    Nov 2006

    Posted 17 Mar 2011 Link to this post

    In EnableLoadOnDemand="true" mode the client side OnClientSelectedIndexChanged event does not get raised when the index value changes from a valid item in the list to an invalid one. I need an event that gets raised whenever the value changes no matter what. How can this be achieved? 

    BTW I tried OnClientTextChange event too and it is also unreliable. It does not get raised in every situation.
  2. Le Duc Hieu
    Le Duc Hieu avatar
    12 posts
    Member since:
    Mar 2011

    Posted 17 Mar 2011 Link to this post

    hi  Bort.

    u can set your rabcombobox AutoPostBack property to true value, i think it will be ok.

    AutoPostBack="true"

    if it still not working, can u show your source code so that we can discuss and resolve it easier?

    best regards.
  3. Bort
    Bort avatar
    10 posts
    Member since:
    Nov 2006

    Posted 18 Mar 2011 Link to this post

    AutoPostBack? why? I don't want to post back. I want to capture the event on the client side. Anyway I tried it and it doesn't change a thing.

    Here is the script in the page.

               function testEvent(sender, eventArgs) {
                    var combo = $find('Customer');
                    alert(combo.get_value() + " : " + combo.get_text());        
                }

    Here is the control definition:

    <telerik:RadComboBox ID="Customer" runat="server" Width="200px" DropDownWidth="405px" Height="225" OnClientSelectedIndexChanged="testEvent" HighlightTemplatedItems="true" ExpandAnimation-Duration="0" CollapseAnimation-Duration="0" EnableLoadOnDemand="true" EnableEmbeddedSkins="false" Skin="Vista">
         <ItemTemplate>
               <span style="width:50;overflow:hidden;white-space:nowrap;">
                      <%#DataBinder.Eval(Container.DataItem, "ID")%>                   
               </span>                                    
               <span style="width:164;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:4;">
                       <%#DataBinder.Eval(Container.DataItem, "LastFirstName")%>
               </span>              
               <span style="width:164;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:4;">
                       <%#DataBinder.Eval(Container.DataItem, "Address")%>
               </span>                                                               
          </ItemTemplate>                                             
    </telerik:RadComboBox>

    and the code behind:

            Protected Sub Customer_ItemsRequested(ByVal o As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) Handles Customer.ItemsRequested
                Dim strPrefixText As String = e.Text.Trim

                If strPrefixText <> Nothing Then
                    With Me.Customer
                        .DataSource = DAL.GetReader(String.Format(
                            "SELECT Top 100 ID, LastFirstName, Address " &
                            "FROM CustomersView WHERE LastFirstName LIKE '{0}%' ORDER BY LastFirstName", DBQuoteFix(strPrefixText)))
                        .DataValueField = "ID"
                        .DataTextField = "LastFirstName"
                        .DataBind()
                        .DataSource.Close()
                    End With
                End If

            End Sub

    How to reproduce the problem:
    - Select an item from the list.
    - Item gets selected and event is raised normally
    - Now go to the end of the text and delete a few characters so that text no longer matches any items in the list
    - No event is raised even though the client value and posted ID value has changed to blank

  4. Le Duc Hieu
    Le Duc Hieu avatar
    12 posts
    Member since:
    Mar 2011

    Posted 18 Mar 2011 Link to this post

    hi Bort

    u change your script into the code i give bellow and it will be resolved.

            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    function testEvent(sender, args) {
                        var combo = $find("<%= Customer.ClientID %>");
                        alert(combo.get_value() + " : " + combo.get_text());   
                    }
                </script>
            </telerik:RadScriptBlock>

    best regards.
  5. Bort
    Bort avatar
    10 posts
    Member since:
    Nov 2006

    Posted 18 Mar 2011 Link to this post

    Only difference I see here is you have:
    var combo = $find("<%= Customer.ClientID %>");
    And I have:
    var combo = $find('Customer');

    But both resolve to the same thing. My "Customer.ClientID" is "Customer". But I tried it anyway to make sure. No difference.
    Again the problem is that the testEvent does not get raised by the control reliably not that it's content is not working. When it gets called it works fine. The event fails to be raised when the item is changed from one in the list to one that is no longer in the list. Please, read my last post again about how to reproduce this event fail.

Back to Top