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

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

1 Answer 47 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 08 Aug 2012, 10:02 PM
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? 

1 Answer, 1 is accepted

Sort by
0
Jeremy
Top achievements
Rank 1
answered on 08 Aug 2012, 10:51 PM
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);
                    }
                }
            });
        });
Tags
ComboBox
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Jeremy
Top achievements
Rank 1
Share this question
or