4

更新する必要がある剣道 ui グリッドがあります。したがって、次のマークアップがあります。

次のスクリプトを呼び出して、ドロップダウン リストに入力します。

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

        }
    });

ページが読み込まれたら。同じスクリプトを呼び出して、ドロップダウン リストを更新します。ソースで、データ ソースに新しいデータが含まれていることに気付きましたが、ドロップダウン リストは非表示になっています。

剣道ドロップダウンリストを更新する正しい方法は何ですか?

4

1 に答える 1

7

kendo DropDownListを初期化する必要があるのは1回だけで、データを更新するたびに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);    

    }
});
于 2012-10-15T19:21:07.883 に答える