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

OnEntryAdded / OnEntryRemoved not firing!

4 Answers 229 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
mqsash
Top achievements
Rank 1
mqsash asked on 14 Feb 2013, 12:51 AM
Hi

I have the following markup defining an autocomplete box and the event handler function.
The autocompletebox works fine - that it displays the suggestions as I type and I can select / remove entries.
Unfortunately when I change the autocomplete selection (add or remove selected entries) the OnEntryAdded / OnEntryRemoved are not being fired. Any idea what I might be missing?

I might be missing something very basic here... but I just don't see it.
Any help will be most appreciated.

Thanks

<telerik:RadAutoCompleteBox
   ID="OperatorAutoCompleteBox"
  runat="server"
  DropDownHeight="150"
  EmptyMessage="(Select Operator)"
  DataSourceID="sqlOperatorsLookupList"
  DataTextField="Full_Name"
  DataValueField="Operator_ID"
  Filter="Contains"
  InputType="Text"
  OnEntryAdded="OperatorAutoCompleteBox_SelectedOperatorChanged"
  OnEntryRemoved="OperatorAutoCompleteBox_SelectedOperatorChanged"
  AutoPostBack="true">
 
 </telerik:RadAutoCompleteBox>

  Protected Sub OperatorAutoCompleteBox_SelectedOperatorChanged(sender As Object, e As AutoCompleteEntryEventArgs)
    do something here...
  End Sub

4 Answers, 1 is accepted

Sort by
0
mqsash
Top achievements
Rank 1
answered on 14 Feb 2013, 01:23 AM
hmm... if only I read the documentation more thoroughly... The EntryAdded is available only if InputType is set to "token" :(
http://www.telerik.com/help/aspnet-ajax/autocompletebox-onentryadded.html

Unfortunately, I can't use Tokens because I want to restrict the user to select only one value, which only works with InputType="Text".

For autocompletes with InputType="Text" use the TextChangedEvent!  
http://www.telerik.com/help/aspnet-ajax/autocompletebox-ontextchanged.html

But in this case when I try to read the value of the selected entry I get a blank!
The Entries(0).Text has the displayed text of the selected entry but the Entries(0).value is blank!
If all I do is remove the "OnTextChanged="{myhandler}"  from the markup, the codebehind is starts to return the correct value in the the Entries(0).Value.
Seems like having the OnTextChanged handler defined causes the control to no longer know the corresponding "value" of the selected "text".

Is that a bug? I am using v 2012.3.1308.

Thanks
0
Mark Kucera
Top achievements
Rank 1
answered on 18 Feb 2013, 07:57 PM
Yeah, i was just getting ready to post something similar to this.  This control is absolutely frustrating.  Probably because it has so much potential but it seems to have such a lousy implementation.  It would be better for Telerik to split this into two separate controls and not have the InputMode attribute..  The input mode drives the display of the control, but apparently it also drives functionality because certain events only fire when you are using a specific input mode.  This is in the documentation, but it's absolutely nuts..  It's also crazy that the only way to restrict a user to selecting one item is in text mode.  but when you are in text mode you lose the ability to select an entity that has both a name and a value.  This is ridiculous.  I want single select functionality of the text mode combined with the entity name/value aspect of the token mode editing. 

-Mark
0
Nencho
Telerik team
answered on 18 Feb 2013, 07:57 PM
Hello S S,

I am not quite sure that I understood your scenario and how exactly you encountered the issue. Could you specify with which  Input you have faced the issue? In addition, you could easily restrict the user to select only one entry, when the InputType is set to Token, with handling the OnClientDropDownOpening and verifying the count of the entered entries. Please consider the following implementation:

function OnClientDropDownOpening(sender, eventArgs) {
 
            if (sender.get_entries().get_count() > 0) {
                eventArgs.set_cancel(true);
            }
 
        }



Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Mark Kucera
Top achievements
Rank 1
answered on 18 Feb 2013, 09:50 PM
This seems to work, so i'm going with it for now.  I think the overall issue is that its up to us, the developers to implement single-select for token input when it's already implemented for text input..
Tags
AutoCompleteBox
Asked by
mqsash
Top achievements
Rank 1
Answers by
mqsash
Top achievements
Rank 1
Mark Kucera
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or