issue using push on ObservableArray

2 posts, 0 answers
  1. Maxim Konstantinovski
    Maxim Konstantinovski avatar
    63 posts
    Member since:
    Mar 2007

    Posted 25 Apr 2014 Link to this post

    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>




  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 28 Apr 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top