Hi,
Populating ObservableArray using ajax does not trigger combobox refresh when ObservableArray initialized using empty array. What is the reason for this behavior?
This works (jsfiddle):
This does not work (jsfiddle):
Populating ObservableArray using ajax does not trigger combobox refresh when ObservableArray initialized using empty array. What is the reason for this behavior?
This works (jsfiddle):
var
vm = kendo.observable(
new
function
() {
var
self =
this
;
self.data =
new
kendo.data.ObservableArray([{}]);
self.selection = 0;
setTimeout(
function
() {
self.data.empty();
self.data.push(
{ id: 0, name:
"E1"
},
{ id: 1, name:
"E2"
},
{ id: 2, name:
"E3"
}
);
}, 30);
});
kendo.bind($(
"#sample"
), vm);
This does not work (jsfiddle):
var
vm = kendo.observable(
new
function
() {
var
self =
this
;
self.data =
new
kendo.data.ObservableArray([]);
self.selection = 0;
setTimeout(
function
() {
self.data.empty();
self.data.push(
{ id: 0, name:
"E1"
},
{ id: 1, name:
"E2"
},
{ id: 2, name:
"E3"
}
);
}, 30);
});
kendo.bind($(
"#sample"
), vm);
<
div
id
=
"sample"
>
<
select
data-role
=
"combobox"
data-text-field
=
"name"
data-value-field
=
"id"
data-bind
=
"value: selection, source: data"
>
</
select
>
</
div
>