How can I do a one time popoulate radcombobox on page load?

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    14 posts
    Member since:
    Mar 2012

    Posted 08 Aug 2012 Link to this post

    I'm trying to populate a RadComboBox on $(document).ready

    The information comes from an .ashx file that renders the json for me. Currently, with a normal dropdownlist, i would add the following script:

               $(document).ready(function () {            
                $.ajax({
                    url: "ResponsePages/Assignees.ashx?userID=" + $("#hfCurrentUserGuid").val(),
                    data: "",
                    type: "GET",
                    datatype: 'json',
                    success: function (data) {
                        var list = $("#cboAssignees");
                        $.each(data, function () {
                            list.append($("<option />").val(this.Guid).text(this.Name));
                        });
                    }
                });
            });

    And this works fine. Needless to say, this doesn't work with the rad control. So my question is how can I achieve this same effect with the RadComboBox? 
  2. Jeremy
    Jeremy avatar
    14 posts
    Member since:
    Mar 2012

    Posted 08 Aug 2012 Link to this post

    Nevermind, I got it lol. Was just trying to use the longhand version:

    $(document).ready(function () {
                $.ajax({
                    url: "ResponsePages/Assignees.ashx?userID=" + $("#hfCurrentUserGuid").val(),
                    data: "",
                    type: "GET",
                    datatype: 'json',
                    success: function (data) {
                        var radList = $find("<%= radCbo.ClientID %>");
                        var items = data.d || data;
                        for (var i = 0; i < items.length; i++) {
                            var item = items[i];
                            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
                            comboItem.set_text(item.Name);
                            comboItem.set_value(item.Guid);
                            radList.get_items().add(comboItem);
                        }
                    }
                });
            });
Back to Top