Item select event (InputType Text)

10 posts, 2 answers
  1. Martin Roussel
    Martin Roussel avatar
    246 posts
    Member since:
    Jan 2010

    Posted 14 Jan 2013 Link to this post

    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
  2. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 17 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Martin Roussel
    Martin Roussel avatar
    246 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2013 Link to this post

    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
  5. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 17 Jan 2013 Link to this post

    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.
  6. Martin Roussel
    Martin Roussel avatar
    246 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2013 Link to this post

    Thanks Bozhidar, cant wait to see the new control also!
  7. Martin Roussel
    Martin Roussel avatar
    246 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2013 Link to this post

    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

  8. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 18 Jan 2013 Link to this post

    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.
  9. Brandon
    Brandon avatar
    6 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    Is there an ETA for the server/client "Item Selected" event?
  10. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 16 Apr 2013 Link to this post

    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.
  11. Brandon
    Brandon avatar
    6 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2013 Link to this post

    Excellent, thank you! Not sure how I missed that!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017