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

3 posts, 0 answers
  1. David
    David avatar
    10 posts
    Member since:
    Dec 2010

    Posted 22 Jul 2011 Link to this post

    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. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 22 Jul 2011 Link to this post

    Hello David,

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

    I hope that helps.
  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Jul 2011 Link to this post

    Hello Kevin,

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

    Thanks,
    Shinu.
Back to Top