У меня есть поле со списком Kendo UI, которое заполнено списком элементов. У меня есть две кнопки: одна для Incrementing и одна для Decrementing index в combobox. Кнопки имеют функции, связанные с событием клика.
Проблема в том, что индекс combobox (показанное значение не изменяется) не увеличивается или не уменьшается. Вот что я имею в качестве методов:
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
}
}
Спасибо за помощь!
Я считаю, что ваша проблема заключается в том, что вы вызываете метод .select()
для элемента jQuery $('#comboTraveler)
вместо переменной combobox
, которая является $('#comboTraveler)
со combobox
Kendo. В ваших if-утверждениях попробуйте это вместо:
combobox.select(selectedIndex + 1);
... и затем, конечно, selectedIndex - 1
в вашем методе DecrementTraveler()
.