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

Client-Side API: ClientID, ID... something?

2 Answers 148 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 Jul 2011, 01:37 PM
Hello, all

I'm trying to tie into the OnClientKeyPressed event of the RadCombobox (really wished you had an onclientkeyup event, but...). My RadCombobox is in a grid, which makes it difficult to assess its ClientID. I've been scouring through the Client-Side-API, which implies I could just reference the ClientID, or the ID, however both of these are returning "undefined". Since it is an OnKeyPressed event, I could just set a reference to the control, and then do some jquery to tie into the OnKeyUp event on client-side, but this seems "hacky". I wanted to know if there is a more "blessed" solution. My code is as follows:

 

<script language="javascript" type="text/javascript"
  
   
  
function getAutocompleteItems(sender, eventArgs) {
  
    alert(sender.ClientID)  // returns "undefined" 
  
   
  
    alert(sender.ID) // returns "undefined" 
  
    //var cboItem = new Telerik.Web.UI.RadComboBoxItem(); 
  
    //cboItem.set_text("Help... somebody!!!"); 
  
    sender.trackChanges();
  
   
  
    var items = sender.get_items()
  
    for (var i = 0; i < items.get_count(); i++) {
  
        if (!items.getItem(i).get_text().toLowerCase().indexOf(sender.get_text().toLowerCase()) == 0) {
  
        items.remove(items.getItem(i));
  
        }
  
    }
  
    //sender.get_items().add(cboItem); 
  
    sender.commitChanges();
  
}
  
</script>
<telerik:GridTemplateColumn DataField="LineItem" UniqueName="grdColHostIDDef"
  
<HeaderStyle Width="0%" HorizontalAlign="Center"/> 
  
<ItemStyle HorizontalAlign="Center" Width="0%" VerticalAlign="Top" /> 
  
<ItemTemplate
  
<span class="validatable"><telerik:RadComboBox runat="server" ID="ddlHostValue" 
  
 CollapseAnimation-Duration="1" 
  
ExpandAnimation-Duration="1" 
  
ExpandAnimation-Type="Linear" 
  
AllowCustomText="true" 
  
CausesValidation="false" 
  
DataSourceID="HostTypeDataSource" 
  
DataTextField="Value" 
  
DataValueField="Value" 
  
OnClientKeyPressing="getAutocompleteItems" 
  
/> 
  
</telerik:GridTemplateColumn
  
  

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 22 Jul 2011, 01:41 PM
Hello David,

To get the controls id, you would use: sender.get_id().

I hope that helps.
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2011, 02:22 PM
Hello Kevin,

Also take a look in to the following help article for more on RadComboboxObject.
RadComboBox Object.

Thanks,
Shinu.
Tags
ComboBox
Asked by
David
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or