0

アイテムのリストが入力された Kendo UI コンボボックスがあります。コンボボックスのインデックスをインクリメントするためのボタンとデクリメントするためのボタンの 2 つのボタンがあります。ボタンには、クリック イベントに関連付けられた機能があります。

問題は、コンボボックスのインデックス (表示されている値が変更されていない) がインクリメントまたはデクリメントされていないことです。メソッドとして私が持っているものは次のとおりです。

   function IncrementTraveler() {
    var combobox = $("#comboTraveler").data("kendoComboBox");
    var selectedIndex = parseInt(combobox.select());
    alert(selectedIndex);  // displays correct index

    if (selectedIndex < combobox.dataSource.data().length) {
        $('#comboTraveler').select(selectedIndex + 1);  // nothing changes
    }
}

function DecrementTraveler() {
    var combobox = $("#comboTraveler").data("kendoComboBox");
    var selectedIndex = parseInt(combobox.select());
    alert(selectedIndex);  // displays correct index

    if (!(selectedIndex < 0)) {
        $('#comboTraveler').select(selectedIndex - 1);  // nothing changes
    }
}

助けてくれてありがとう!

4

1 に答える 1

1

あなたの問題は、Kendo コンボ ボックス オブジェクトである変数ではなく.select()、jQuery 要素でメソッドを呼び出していることだと思います。if ステートメントで、代わりにこれを試してください。$('#comboTraveler)combobox

combobox.select(selectedIndex + 1);

...そしてもちろんselectedIndex - 1、あなたのDecrementTraveler()方法で。

于 2014-03-31T19:48:51.100 に答える