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

looping through combox items

1 Answer 179 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Binary
Top achievements
Rank 1
Binary asked on 25 Sep 2015, 03:09 PM

I have the telerik radcombox and I want to loop through all the items on that radcombox before adding any element to it. I want to achieve this at client side.I tried this code but it did not give result I was expecting for. I have application which will add items to the radcombox but before that I want to check element is already there or not. Not sure why my below code is not working.

 

var combo = $find("<%= MyCombo.ClientID %>");

var items = combo.get_items();

for (var i = 0; i < items._array.length; i++) {

    var myradcomboValues= items.getItem(i);

  alert(myradcomboValues);

}

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 30 Sep 2015, 09:22 AM
Hi Binary,

Please try the following snippet and let me know about the result:
function pageLoad(app, args) {
    var combo = $find('<%= RadComboBox1.ClientID %>');
    var items = combo.get_items();
    for (var i = 0; i < items.get_count() ; i++) {
        var item = items.getItem(i);
        var value = item.get_value();
        alert(value);
    }
}

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Binary
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or