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

how to capture event when value changes

4 Answers 88 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bort
Top achievements
Rank 1
Bort asked on 18 Mar 2011, 02:37 AM
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.

4 Answers, 1 is accepted

Sort by
0
Le Duc Hieu
Top achievements
Rank 2
answered on 18 Mar 2011, 03:29 AM
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.
0
Bort
Top achievements
Rank 1
answered on 18 Mar 2011, 05:45 AM
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

0
Le Duc Hieu
Top achievements
Rank 2
answered on 18 Mar 2011, 07:43 AM
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.
0
Bort
Top achievements
Rank 1
answered on 18 Mar 2011, 10:40 AM
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.

Tags
ComboBox
Asked by
Bort
Top achievements
Rank 1
Answers by
Le Duc Hieu
Top achievements
Rank 2
Bort
Top achievements
Rank 1
Share this question
or