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

Add AutoCompleteSeparator automatically

4 Answers 83 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 04 Mar 2009, 11:30 AM
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

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2009, 12:46 PM

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.
0
Jeff
Top achievements
Rank 1
answered on 04 Mar 2009, 01:06 PM
Thanks Princy that was spot on :)
0
Scott
Top achievements
Rank 2
answered on 02 Jun 2009, 09:38 PM
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.
0
Shinu
Top achievements
Rank 2
answered on 03 Jun 2009, 09:32 AM
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.
Tags
ComboBox
Asked by
Jeff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Scott
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or