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

[Solved] Problem using client side code for combobox

1 Answer 130 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeanne Kornkven
Top achievements
Rank 1
Jeanne Kornkven asked on 16 Feb 2010, 11:44 PM
I want to add an item to the RadComboBox on the client side.  I have copied the suggested code, but it does not work.  The error comes at the line combo.get_items().add(comboItem);. The error message is 'undefined' is null or not an objet
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="pnl_iChoose_Hrchy.ascx.vb" 
    Inherits="WebUserControls_pnl_iChoose_Hrchy"%> 
<asp:Panel ID="pnlAjax" runat="server" >      
    <table class="tblPanel" > 
        <col class="leftCell" /> 
        <col class="rightCell" /> 
        <tr> 
            <td> 
                Dept:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlDepartment" AutoPostBack="true" EnableLoadOnDemand="True" 
                    ShowDropDownOnTextboxClick="false" OnClientSelectedIndexChanged="ddlDept_SelIChng">  
                    <WebServiceSettings Method="loadDepartment" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Class:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlClass" AutoPostBack="true" EnableLoadOnDemand="True" 
                    OnClientItemsRequesting="hrchy_itmReq_Dpt">  
                    <WebServiceSettings Method="loadClass" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Subclass:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlSubClass" AutoPostBack="true" EnableLoadOnDemand="True">  
                    <WebServiceSettings Method="loadSubClass" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Vendor:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlSupplier" AutoPostBack="true" EnableLoadOnDemand="True">  
                    <WebServiceSettings Method="loadVendor" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Vendor Style:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlStyle" AutoPostBack="true" EnableLoadOnDemand="True">  
                    <WebServiceSettings Method="loadStyle" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox>                 
            </td> 
        </tr> 
        <tr> 
            <td> 
                SEA CDE:  
            </td> 
            <td> 
                <telerik:RadComboBox runat="server" ID="ddlSeason" EnableLoadOnDemand="True">  
                    <WebServiceSettings Method="loadSeaCde" Path="../WebServices/srvc_ComboBox.asmx" /> 
                </telerik:RadComboBox> 
            </td> 
        </tr> 
         <tr> 
            <td> 
                Vendor PID:  
            </td> 
            <td> 
                <telerik:RadTextBox ID="txtPID" runat="server">  
                    <ClientEvents OnFocus="ShowResultTab" OnKeyPress="RetrieveOnEnter" /> 
                </telerik:RadTextBox></td>  
        </tr> 
        <tr> 
            <td> 
                Created Since:  
            </td> 
            <td> 
                <telerik:RadDatePicker runat="server" Skin="WebBlue" ID="dpSince" SharedCalendarID="sharedCal" 
                    Width="80px" > 
                    <DateInput ID="diSince" runat="server" onclick="dp_PUpdating(this.id);">  
                    </DateInput> 
                    <DatePopupButton ImageUrl="~/App_Themes/BlueBT2009/Calendar/Cal.gif" onclick="dp_PUpdating(this.id);" /> 
                </telerik:RadDatePicker> 
            </td> 
        </tr>    
          
    </table> 
    <telerik:RadCalendar runat="server" ID="sharedCal">  
    </telerik:RadCalendar>   
       
</asp:Panel> 
 This RadComboBox is on a user control that is contained in a RadPanelItem.  The RadPanelItem is contained in a RadPane.  The RadPane is contained in a RadSplitter.
 function pnlHierarchyBackFeed(sql) {  
            try {  
                var sqlt = trim(sql);  
                var arry = sqlt.split(' '); ;  
                var combo;  
                var str;  
                var x;  
                for (x in arry) {  
                    str = arry[x + 2];  
                    switch (arry[x]) {  
                        case 'DEPT_ID':  
                            combo = $find("<%= Me.ddlDepartment.ClientID %>");  
                            var comboItem = new Telerik.Web.UI.RadComboBoxItem();  
                            comboItem.set_text(str);  
                            combo.trackChanges();  
                            combo.get_items().add(comboItem);  
                            comboItem.select();  
                            combo.commitChanges();  
                            break;  
                        case 'CLASS_ID':  
                            combo = $find("<%= Me.ddlClass.ClientID %>");  
                            var comboItem = new Telerik.Web.UI.RadComboBoxItem();  
                            comboItem.set_text(str);  
                            combo.trackChanges();  
                            combo.get_items().add(comboItem);  
                            comboItem.select();  
                            combo.commitChanges();  
                            break;  
                        
                        default:  
                             
                    }  
                    x = x + 2;  
                }  
            }  
            catch (err) {  
                alert(err.message);  
            }  
        } 

1 Answer, 1 is accepted

Sort by
0
Jeanne Kornkven
Top achievements
Rank 1
answered on 17 Feb 2010, 02:12 AM
I've found the problem, and it is not with the combobox.  The issue was with my subscripting.
Tags
ComboBox
Asked by
Jeanne Kornkven
Top achievements
Rank 1
Answers by
Jeanne Kornkven
Top achievements
Rank 1
Share this question
or