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

combo.get_items() error

0 Answers 31 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 20 Dec 2014, 04:54 PM
Hello,I want to add an item to a Radcombox by Javascript.
Here is my code

        function get_data(combobox) {

            var hdcatvalue = document.getElementById("hdcatvalue");
            var combo = $find(combobox);
            combo.trackChanges();
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();

            var request = new XMLHttpRequest();  // Create new request
            request.open("GET", "getvalue.aspx", false);     // Pass false for synchronous
            request.send(null);
            var textval = request.responseText; // '<%=Session["catvalue"] %>';
            var mySplitResult = textval.split("|");
            var gText = mySplitResult[0];
            textval = mySplitResult[1];

            if (hdcatvalue.value != gText && gText != "") {
                comboItem.set_text(gText);
                comboItem.set_value(textval);               
                combo.get_items().add(comboItem);
                combo.commitChanges();
            }
           hdcatvalue.value = gText;
   }
I call the prevous function through OnClientFocus client event

When I try to open the dropdownlist nothing populate (not opened ), but  when I remove:
* combo.trackChanges();
* combo.get_items().add(comboItem);
* combo.commitChanges();

The combobox works fine. Please advice.

Thank you

     







No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Ahmed
Top achievements
Rank 1
Share this question
or