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

Add items to RadComboBox error

4 Answers 148 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Francisco Tirado
Top achievements
Rank 1
Francisco Tirado asked on 07 Jul 2010, 06:24 PM
Hello, I have a trouble adding items to RadComboBox in client side.
I tried to add items in two different ways:

In this way:
    FillServiceTypes: function () {
        var i = 0;
        var servTypeComboBox = $find("<%= rcbServiceTypes.ClientID%>");
        for (i = 0; i <= 5; i++) {
            var rcbItem = new Telerik.Web.UI.RadComboBoxItem();
            rcbItem.set_text("Item " + i);
            rcbItem.set_value(i);
            servTypeComboBox.trackChanges();
            servTypeComboBox.get_items().add(comboItem);
            servTypeComboBox.select();
            servTypeComboBox.commitChanges();
        }
    }

And in this other:
    FillServiceTypes: function () {
        var i = 0;
        var items = [];
        var servTypeComboBox = $find("<%= rcbServiceTypes.ClientID%>");
        for (i = 0; i <= 5; i++) {
            var rcbItem = new Telerik.Web.UI.RadComboBoxItem();
            rcbItem.set_text("Item " + i);
            rcbItem.set_value(i);
            items[items.length] = rcbItem;
        }
        servTypeComboBox.insertItems(items);
    }

In both ways i received this error:
Microsoft JScript runtime error: Object doesn't support this property or method

Can someone help me how to resolve this trouble?, please.
Thanks in advance.

Francisco.


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Jul 2010, 08:41 AM
Hello Francisco,


I suppose the problem occurred because you are calling select() and insertitems() methods for RadComboBox client object which are not there (not supported). And you can call select() method for RadComboBoxItem (not RadComboBox) client object to select the particular item.

Try with the following client code:

JavaScript:
FillServiceTypes: function() {
    var i = 0;
    var servTypeComboBox = $find("<%= rcbServiceTypes.ClientID%>");
    for (i = 0; i <= 5; i++) {
        var rcbItem = new Telerik.Web.UI.RadComboBoxItem();
        rcbItem.set_text("Item " + i);
        rcbItem.set_value(i);
        servTypeComboBox.trackChanges();
        servTypeComboBox.get_items().add(rcbItem);
        //  servTypeComboBox.select();
        servTypeComboBox.commitChanges();
    }
}


Happy coding ;)
Shinu.
0
Francisco Tirado
Top achievements
Rank 1
answered on 09 Jul 2010, 03:07 PM
Thank you for reply, but I still getting the same error: "Object doesn't support this property or method".
The lines where I received the errors are:

In the first piece of code
servTypeComboBox.trackChanges();
servTypeComboBox.get_items().add(comboItem);
servTypeComboBox.select();
servTypeComboBox.commitChanges();

When I place the cursor on any of these functions, I get "undefined" for the function definition.
I attach an image with the "undefined" function.

In the second piece of code I received  the error in this line
servTypeComboBox.insertItems(items);

Cheers.
Francisco
0
Kalina
Telerik team
answered on 14 Jul 2010, 06:37 AM
Hello Francisco Tirado,

As I understand you are trying to select a RadComboBoxItem at client-side with RadComboBox.select() - there is no such function supported and that is why you receive an error.

Please use RadComboBoxItem.select() instead:
FillServiceTypes: function() {
    var i = 0;
    var servTypeComboBox = $find("<%= rcbServiceTypes.ClientID%>");
    for (i = 0; i <= 5; i++) {
        var rcbItem = new Telerik.Web.UI.RadComboBoxItem();
        rcbItem.set_text("Item " + i);
        rcbItem.set_value(i);
        servTypeComboBox.trackChanges();
        servTypeComboBox.get_items().add(rcbItem);
        //  servTypeComboBox.select(); - this is not a function
        servTypeComboBox.commitChanges();
    }
     
    // find an item to select
    var selectedItem = servTypeComboBox.findItemByValue(5);
    selectedItem.select();
}

You can find more details about RadComboBox client-side methods and properties here.

Kind regards,
Kalina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Francisco Tirado
Top achievements
Rank 1
answered on 15 Jul 2010, 02:24 PM
Thanks for your reply, currently I change the way to fill the RadComboBox now I'm using WebServiceSettings to get the data.
And now I know why I was receiving that error, not for the reason that you say, was I mistake of my side.

Thanks for your help.

Cheers.
Francisco
Tags
ComboBox
Asked by
Francisco Tirado
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Francisco Tirado
Top achievements
Rank 1
Kalina
Telerik team
Share this question
or