Extreme performance issue with Hierachical DS/TreeView when loadOnDemand=false

5 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    Oct 2012

    Posted 29 Nov 2012 Link to this post

    Every node causes a call to _initChildren even if it doesn't have children.

    If i have one root node with 1000 children (leafs w/o children) the call to _initChildren is made 1001 times. If you use load on demand the call is only done for the nodes you expand, and nodes without children can't be expanded. It is obvious that the information on wheter the node has children or not is available before the _initChildren is called. For larges datasources (~1000 nodes) this often causes the browser to halt (alerting ~A script is causing the page to run slowly..).

    By changing kendo.data.js (start line 2832 in 2012.2.913) from:

    load: function() {
        var that = this,
            options = {};
     
        that._initChildren();
     
        if (!that._loaded || that.hasChildren) {
            options[that.idField || "id"] = that.id;
     
            if (!that._loaded) {
                that.children._data = undefined;
            }
     
            that.children.one(CHANGE, function() {
                        that._loaded = true;
                    })
                    ._query(options);
        }
    },

    To:

    load: function() {
        var that = this,
            options = {};
     
        if (that.hasChildren)
        {
            that._initChildren();
     
            options[that.idField || "id"] = that.id;
     
            if (!that._loaded) {
                that.children._data = undefined;
            }
     
            that.children.one(CHANGE, function() {
                        that._loaded = true;
                    })
                    ._query(options);
        }
    },

    The loading time is cut by ~80% (one typical example would be from 30s to 7s) in my average trees (a lot more in the example given above).

    Though I don't now it the above code change can have any unforseen consequences, or if there is a better way to accomplish a similar effect.

    Would love to hear you thoughts on this.

  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 30 Nov 2012 Link to this post

    Hello David,

    Thank you for reporting this. The said change will break the append/insertBefore/insertAfter operations in the treeview, because the items will not have valid child datasources after load() -- leaf nodes do not have their hasChildren flag set, and calling load() will not initialize their child datasource.

    We are looking for a resolution of this problem at this time, and I'll update this thread with our findings later today.

    Regards,
    Alex Gyoshev
    the Telerik team
    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
  4. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 30 Nov 2012 Link to this post

    Hello again,

    The last issue that I described can be addressed by adding the following lines to the _dataSourceMove method from kendo.treeview.js:

    // kendo.treeview.js : _dataSourceMove()
    // OLD
    if (parentNode != this.root) {
        destDataSource = referenceDataItem.children;
    }

    // NEW
    if (parentNode != this.root) {
        destDataSource = referenceDataItem.children;

        if (!destDataSource || $.isPlainObject(destDataSource)) {
            referenceDataItem._initChildren();
            destDataSource = referenceDataItem.children;
        }
    }

    // kendo.data.js : load()
    // OLD
    that._initChildren();

    if (!that._loaded || that.hasChildren) {

    // NEW
    if (that.hasChildren) {
        that._initChildren();

    However, this will break any user code that has accesses the children field without checking whether it exists. Since we are reluctant to add such a breaking change in the internal builds, we will introduce this change in a future official release.

    All the best,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Sean Smith
    Sean Smith avatar
    1 posts
    Member since:
    Nov 2006

    Posted 18 Jan 2013 Link to this post

    Is this issue the same as this item from a recent release notes document?

    Loading nodes with hasChildren=false queries the child data source

    It seems that it was an issue that was fixed, but that does not appear to be the case. If not, can you please provide the min version of the code to replace?
  6. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 21 Jan 2013 Link to this post

    Hello Sean,

    While this fix improves the overall HDS performance, it is not the same issue. Alas, since the service pack is a non-breaking release, so the breaking change will be introduced in the 2013.Q1 release.

    Please note that we do not provide updated files in public threads. If you need an updated version of any file, please request it through a support ticket.

    All the best,
    Alex Gyoshev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready