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

How do I do a manual update of a kendoComboBox list?

1 Answer 214 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 20 Dec 2011, 06:49 PM

Could you please set me straight?  I am initializing and kendo combobox with a simple call to kendoComboBox() which is causing it to load it's list from the select list that is rendered in html output which is great.  I then come along later and trigger a refresh of that list via the following function based on the selection of another combobox...
IIHS.EditPlanningVehicle.RefreshSeries = function (planningYear, makeName) {
    //Load a new list of options for vehicle definitions
    $.getJSON($("#mainForm #LoadNewListFormat").val().replace("makeName", makeName).replace("planningYear", planningYear),
        function (data) {
            $("#SourceVehicleVariantsId").kendoComboBox(data);
        });
};

This works mostly, but ends up creating a second dropdown element when clicking on the dropdown button for the combobox.  Is there a better way I can assign a new list to the dropdown, or do I need to switch to using dataSources?

Thanks.






1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 22 Dec 2011, 09:39 AM
Hi Peter,

Indeed, the best approach in this case would be to use the DataSource component. The ComboBox (none of the kendo widgets, in fact) does not support multiple initializations on the same DOM element. 

The DataSource transport supports dynamic data values by assigning functions to the keys. Something like this:

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "http://search.twitter.com/search.json",
            dataType: "jsonp",
            data: {
                q: function() { return "html5"; }
            }
        }
    },
    schema: {
        data: "results"
    }
});

Greetings,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Peter
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or