2012-10-15 49 views
4

我有一个kendo ui网格,我需要更新。所以,我有以下的马克 - 达:如何刷新KendoUI DropDownList?

我叫下面的脚本来填充下拉列表:

// 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);  

     } 
    }); 

一旦页面加载。我调用相同的脚本来刷新下拉列表。我注意到源中数据源包含新数据,但下拉列表已隐藏。

什么是更新剑道下拉列表的正确方法?

回答

7

您只需要初始化kendo DropDownList一次,并且每次要刷新数据时都应该使用dataSource.data()方法。

喜欢的东西:

$('#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);  

    } 
});