Add AutoCompleteSeparator automatically

5 posts, 0 answers
  1. Jeff
    Jeff avatar
    29 posts
    Member since:
    Nov 2006

    Posted 04 Mar 2009 Link to this post

    Hi,

    Does anyone know how to add the AutoCompleteSeparator (I use "; ") to the selected item automatically after the user has selected the item in the drop down?  That way the user can then start typing again to chose the next item without having to remember to add the seperator.

    Thanks for your help,

    Jeff
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2009 Link to this post

    Hi Jeff,

    Attach the following client side function to OnClientSelectedIndexChanged of RadComboBox.


    JavaScript:
    <script type="text/javascript">  
    function ClientSelectedIndexChanged(sender, args)  
    {  
        var combo= $find('<%=RadComboBox1.ClientID %>');  
        var text= combo.get_text();  
        combo.trackChanges();  
        combo.set_text(text+';');  
        combo.commitChanges();  
    }  
    </script> 

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff
    Jeff avatar
    29 posts
    Member since:
    Nov 2006

    Posted 04 Mar 2009 Link to this post

    Thanks Princy that was spot on :)
  5. Scott
    Scott avatar
    45 posts
    Member since:
    Apr 2008

    Posted 02 Jun 2009 Link to this post

    This is great.

    With this example: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/autocompleteclientside/defaultcs.aspx
    Once you have selected more than 1 items, how can you remove one of the items of the selection without starting over?

    Idea, what I'm looking for is similar to Hotmail's recipient textbox where I can easily delete any of the members I have already selected.
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Jun 2009 Link to this post

    Hi Scott Rupp,

    Try the following client side code and see whether it working as you expected.

    ASPX:
     
    <telerik:radcombobox id="RadComboBox1" OnClientKeyPressing="OnClientKeyPressing" OnClientSelectedIndexChanged="ClientSelectedIndexChanged" runat="server" allowcustomtext="True" autocompleteseparator=";" width="366px"
    <Items> 
      . . . 
    </Items> 
    </telerik:radcombobox> 

    JavaScript:
     
    <script type="text/javascript"
    var combo, result; 
    function pageLoad() 
        combo = $find('<%=RadComboBox1.ClientID %>');  
    function ClientSelectedIndexChanged(sender, args)   
        var text= combo.get_text();   
        combo.trackChanges();   
        combo.set_text(text+';');   
        combo.commitChanges();   
    }   
    function OnClientKeyPressing(sender, eventArgs) 
       if (eventArgs.get_domEvent().keyCode == 8) // BackSpace 
       { 
            var text= combo.get_text(); 
            var answerIdx = text.substring(0,text.length-1); 
            var lastindex= answerIdx.lastIndexOf(';'); 
            result = text.substring(0,lastindex) +';'
            window.setTimeout("del();",0); 
       } 
    }  
    function del() 
        combo.trackChanges();     
        combo.set_text(result); 
        if(combo.get_text()==';'
        { 
            combo.set_text(''); 
        } 
        combo.commitChanges(); 
    </script>  

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017