This is a migrated thread and some comments may be shown as answers.

issue using push on ObservableArray

1 Answer 208 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Maxim
Top achievements
Rank 1
Maxim asked on 25 Apr 2014, 08:51 PM
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):
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>




1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 28 Apr 2014, 02:27 PM
Hello Maxim,

Thank you for drawing our attention to this issue. We investigated it further and found out that the problem is caused by a lost of the ObservableArray reference. We will address this limitation in the next internal build of Kendo UI. You can review the opened issue here.
As a gratitude for your involvement I updated your Telerik points.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
MVVM
Asked by
Maxim
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or