EasyUI Forum
September 13, 2025, 04:21:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Treegrid - slow rendering and loading, concerning the tree's size  (Read 19560 times)
amir-t
Newbie
*
Posts: 48


View Profile
« on: June 16, 2014, 09:22:15 AM »

Hi,

i'm using Tree-grid in chrome browser, with the dynamic loading methodology (using the 'loader' callback).
We have a serious performance problem with the treegrid, and we noticed that the slow rendering performance is getting worst when more child rows are added to the tree (by expanding parents rows).

It's important to emphasize that our tree-grid size contains about 10-40 rows in every tree level, and generally our tree's total size is about 100-200 rows, which is not a lot.

In addition, in order to find our bottleneck in the slow performance issue, we limited our server's response to a maximum 5 rows for each request (by the dynamic loading), and we found that the loading\rendering started to be slow when we expanded 8-10 rows from different depth levels.where each row can hold maximum of 5 child's rows.

How can we solve this performance problem? Is there a way we can improve the treeGrid rendering performance?

Thanks in advance.
« Last Edit: June 16, 2014, 09:26:04 AM by amir-t » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 16, 2014, 05:34:57 PM »

To improve tree grid performance, set 'autoRowHeight' to false, 'rownumbers' to false and prevent from using 'frozenColumns' property. Please refer to the attached example. The tree grid loads more that 900 rows and runs quickly.
Logged
amir-t
Newbie
*
Posts: 48


View Profile
« Reply #2 on: June 17, 2014, 01:23:17 AM »

Thanks a lot  Smiley

We'll try this specifications, hope it will improve our treeGrid performance.
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #3 on: August 21, 2014, 11:45:22 PM »

I'm having the same problem.  I have tried specifying 'autoRowHeight' false, 'rownumbers' false and I'm not using any frozen columns - but performance is still not good.

I'm using the latest 1.4 version of jQuery EasyUI.  My grid has 17 visible columns and a few hidden columns and then only about 200 rows in it

When I expand (or contract) a node that is already loaded into the tree, it is taking 10+ seconds.  Using Chrome's dev tools and the CPU profiling, I see that the most time is spent in the autoSizeColumn function in datagrid (inherited by treegrid). 

I'm wondering why it has to re-auto size the columns when expanding/collapsing tree nodes in the tree?  In my application, the treegrid columns don't need to be resized in those cases.

Is there a way I can override the autoSizeColumn function so it does nothing during expand/collapse operations but works when the treegrid first loads?

thanks,
Tom
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #4 on: August 22, 2014, 01:20:03 PM »

I figured out how to do this and it did make a big difference in performance for my app's treegrid.  Here is what I did:

Extend the 'autoSizeColumn' method for the treegrid:
Code:
var origTreegrid_autoSizeColumn = $.fn.datagrid.methods['autoSizeColumn'];
$.extend($.fn.treegrid.methods, {
    autoSizeColumn: function(jq, field) {
        $.each(jq, function() {
            var opts = $(this).treegrid('options');
            if (!opts.skipAutoSizeColumns) {
                var tg_jq = $(this);
                if (field) origTreegrid_autoSizeColumn(tg_jq, field);
                else origTreegrid_autoSizeColumn(tg_jq);
            }
        });
    }
});

Then when I setup my treegrid, set skipAutoSizeColumns to 'false' and install handlers to track the expand/collapse operations:

Code:
$('#tg').treegrid({
    fit: true,
    url: 'getMyData',
    skipAutoSizeColumns: false,
    onBeforeExpand: function() {
        $(this).treegrid('options').skipAutoSizeColumns = true;
    },
    onBeforeCollapse: function() {
        $(this).treegrid('options').skipAutoSizeColumns = true;
    },
    onExpand: function() {
        $(this).treegrid('options').skipAutoSizeColumns = false;
    },
    onCollapse: function() {
        $(this).treegrid('options').skipAutoSizeColumns = false;
    }
});
       
The result is the 'autoSizeColumns' method is called normally when the grid data is loaded to get the column sizing initialized properly - but then expanding/collapsing nodes is *much* faster and more responsive -- even if the data needs to be fetched from the server to fill in the children nodes.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!