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

kendo duplicate rendering issue

1 Answer 154 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
leblanc
Top achievements
Rank 1
leblanc asked on 22 Jun 2013, 12:39 AM
a long time ago we modified the kendostore front sample for our internal needs.

specifically store-browse.js

(function ($, kendo, store) {
    var viewModel = kendo.observable({
        Products: {
            data: [],
            total: 0
        },

noticed data is array not DataSource or ObservableArray
 - changing to DataSource throws a recursion error in kendo js file
 - ObservableArray works but suffers from duplicate rendering issue


About: kendo duplicate rendering issue

<section>
    <div class="clearfix" data-role="listView" data-bind="source: Products.data" data-template="product-template"></div>
</section>

attached is image where left side is code causes duplicate rendering randomly.

my hack so i wouldn't have to do major refactoring is on the right . (working - no more doubles)


Can someone explain why doubles happen when pushing into array (left side of code)?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 25 Jun 2013, 01:52 PM
Hi leblanc,

ViewModel.products.data is an ObservableArray (it will be internally transformed by the MVVM when ViewModel is created). There should be no need to manually set the Products.data, the array should trigger its change event as soon as you push something inside it.

I am afraid that the provided information is not sufficient enough in order to determine where exactly the problem comes from. Please remove "viewModel.set("Products.data", ....)" and let me know if the issue still persists.

Regards,
Alexander Valchev
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
leblanc
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or