Javascript 如何刷新KendoUI下拉列表?
我有一个剑道ui网格需要更新。因此,我有以下加价: 我调用以下脚本来填充dropdownlist:Javascript 如何刷新KendoUI下拉列表?,javascript,asp.net-mvc,telerik,kendo-ui,Javascript,Asp.net Mvc,Telerik,Kendo Ui,我有一个剑道ui网格需要更新。因此,我有以下加价: 我调用以下脚本来填充dropdownlist: // An Ajax call to load the selected hover into the controls $.ajax({ type: 'POST', url: '/Reports/HoverManager/GetHoversForDropDown', data: { sectionId: sectionId },
// An Ajax call to load the selected hover into the controls
$.ajax({
type: 'POST',
url: '/Reports/HoverManager/GetHoversForDropDown',
data: { sectionId: sectionId },
error: function(response){
$('.hover-manager .error').html(response.responseText).fadeIn(500).delay(5000).fadeOut(500);
},
success: function(response){
$('.hover-manager #hoverSelect').kendoDropDownList({
animation: false,
dataTextField: "Name",
dataValueField: "ID",
dataSource: response.hovers,
change: hoverDownDownChange,
}).data('kendoDropDownList').value(hoverId);
}
});
一旦页面加载。我调用相同的脚本刷新下拉列表。我在源代码中注意到,数据源包含新数据,但下拉列表是隐藏的
更新剑道下拉列表的正确方法是什么?您只需初始化剑道下拉列表一次,每次要刷新数据时,都应使用方法 比如:
$('#hoverSelect').kendoDropDownList({
animation: false,
dataTextField: "Name",
dataValueField: "ID",
change: hoverDownDownChange,
}).data('kendoDropDownList').value(hoverId);
$.ajax({
type: 'POST',
url: '/Reports/HoverManager/GetHoversForDropDown',
data: { sectionId: sectionId },
error: function(response){
$('.hover-manager .error').html(response.responseText).fadeIn(500).delay(5000).fadeOut(500);
}, success: function(response){
$('#hoverSelect').data('kendoDropDownList').dataSource.data(response.hovers);
}
});