Keep Item selected and still list all items inside combobox when dropdown opened

2 posts, 0 answers
  1. Carina
    Carina avatar
    41 posts
    Member since:
    Nov 2012

    Posted 21 May 2013 Link to this post

    Hi,

    I have a combobox that when it has an item selected I want to go back and select the down arrow and bring up the list of the items in the combobox but keep the selected item until I select a new one. I managed to do it, but I am not sure why it when I first select the combobox dow arrow it brings up only that one item selected and when I click on the down arrow again it does bring up the full list. Please see the attached image to what is goign on. Here is my javascript and aspx:

    <telerik:radcombobox ID="cboDocs" runat="server"  MarkFirstMatch="False" EnableAutomaticLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                        DataSourceID="ObjDataSourc" Width="200px"  EmptyMessage="Select Document" DataTextField="DocName" 
                        OnClientDropDownOpening="dropDownOpening" ToolTip="Select an existing document type to review."
                        DataValueField="DocID"  ItemsPerRequest="12"  Skin="Office2010Blue" AutoPostBack="true"> 

    <
    function dropDownOpening(sender, args) {
                   if (sender.get_text() != "") {
                       sender.set_text(sender.get_text());
                       sender._filterText = "NotIsEmpty";
                       sender.requestItems("");
                       sender.get_items("");
                   }
               }
    >
  2. Plamen
    Admin
    Plamen avatar
    3057 posts

    Posted 24 May 2013 Link to this post

    Hi Carina,

     
    Thank you for contacting Telerik support.

    This issue is observed because the loaded items are generated according to the selected item. Here is the code that worked around this issue at my side:

    function dropDownOpening(sender, args) {
                  var selectedText = sender.get_text();
                  if (selectedText != "") {
                      sender.set_text("");
                  }
                  setTimeout(function myfunction() {
                      sender.set_text(selectedText);
                  }, 20);
              }


    Hope this will be helpful. If you have further questions please don't hesitate to contact us again.

    Regards,
    Plamen
    Telerik
    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.
Back to Top