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

Item select event (InputType Text)

9 Answers 140 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Martin Roussel
Top achievements
Rank 1
Martin Roussel asked on 14 Jan 2013, 06:55 PM
Hi, my RadAutoCompleteBox is like this:

<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Skin="WebBlue" DropDownWidth="150" CssClass="SalesOrderSearch" DataTextField="strSalesOrderNumber" TextSettings-SelectionMode="Single" Filter="Contains" InputType="Text">
 <DropDownItemTemplate>
.
.
.
</DropDownItemTemplate>
</telerik:RadAutoCompleteBox>

I need to detect the event of when user select an item (click from the dropdownlist or "Enter" key press after typing valid entry). However, it doesnt seem easy when InputType is not "Token". The closest I got was to use the OnClientDropDownClosed event (and then validate the text entered) but that's pretty annoying and not really a "user selection". Any clue?

TIA

Martin

9 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 17 Jan 2013, 08:43 AM
Hello Martin,

While this functionality might seem incomplete, we thought that it was the best solution that would cover all cases. When you are in text mode and allow custom tokens, every change in the input field could be considered as adding a new entry. Imagine for instance that you already have text entered in the control. Now you copy another text, select the whole text in the AutoCompleteBox and do a paste action, replacing the text. This is one of the reasons we chose to have only a TextChanged event when in TextMode. 

In your case you can try the following workaround:
Add the following code on the page with the AutoCompleteBox:
var originalHandler = Telerik.Web.UI.RadAutoCompleteBox.prototype._addEntryFromItem;
Telerik.Web.UI.RadAutoCompleteBox.prototype._addEntryFromItem = function(item) {
    console.log('asdas');
    originalHandler.apply(this, [item]);
 
    console.log('entry added from item');
    //You can call your handler function here
}

With this function you are handling the cases where an entry is added when clicking on an item, or pressing enter when an item is highlighted.

I'm also happy to announce that in our next official release we will introduce a new control, called RadSearchBox, which will have the exact functionality you are looking for out of the box, as well as some other cool features.
 

Greetings,
Bozhidar
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
Martin Roussel
Top achievements
Rank 1
answered on 17 Jan 2013, 01:18 PM
Thanks Bozhidar,

your workaround seem to be better than mine since I dont have to validate if the entry actually exists.

Another problem: You mentioned replacing the highlighted text by pasting copied text but this doesnt seem to be possible when an entry has already been selected. It seems the user has to erase the shown text completely to be able to paste. Is there a way to highlight the existing text (to easily "over-paste")? I know my user will be annoyed by this.

TIA


Martin
0
Accepted
Bozhidar
Telerik team
answered on 17 Jan 2013, 02:23 PM
Hello Martin,

This is possible only when you have set the AllowCustomEntry="true"
 

Kind regards,
Bozhidar
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
Martin Roussel
Top achievements
Rank 1
answered on 17 Jan 2013, 04:05 PM
Thanks Bozhidar, cant wait to see the new control also!
0
Martin Roussel
Top achievements
Rank 1
answered on 17 Jan 2013, 05:53 PM
Bozhidar, I forgot to ask if the RadSearchBox will contain a SERVER-side event of when an item has been selected/enter pressed? I really need this feature and it seems I cant do it with the RadAutoCompleteBox.

Thanks

Martin

0
Bozhidar
Telerik team
answered on 18 Jan 2013, 07:14 AM
Hi Martin,

Yes, there will be a server, as well as a client event for this action.
 

Kind regards,
Bozhidar
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
Brandon
Top achievements
Rank 1
answered on 15 Apr 2013, 04:59 PM
Is there an ETA for the server/client "Item Selected" event?
0
Bozhidar
Telerik team
answered on 16 Apr 2013, 06:59 AM
Hello Brandon,

RadSearchBox supports the event from its first release. However the event is called OnSearch ( and respectively OnClientSearch ). You can see how it works in the following demo:
http://demos.telerik.com/aspnet-ajax/searchbox/examples/programming/serverevents/defaultcs.aspx

 

All the best,
Bozhidar
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
Brandon
Top achievements
Rank 1
answered on 16 Apr 2013, 09:15 PM
Excellent, thank you! Not sure how I missed that!
Tags
AutoCompleteBox
Asked by
Martin Roussel
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Martin Roussel
Top achievements
Rank 1
Brandon
Top achievements
Rank 1
Share this question
or