EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Overwhelmer on April 07, 2014, 05:33:25 AM



Title: [treegrid] autoSizeColumn just one time and not every LoadData
Post by: Overwhelmer on April 07, 2014, 05:33:25 AM
Hello,
i am using the treegrid component.
I am performing lazy loading of the node children as described on the documentation.

In order to make the grid fit better with the data I load I want to use the autoSizeColumn like this:
Code:
 if(this.firstLoad)
 {
     var fields = this.$treegrid.treegrid('getColumnFields'); 
     for(var i=0; i<fields.length; i++){ 
         var field = fields[i];             
         this.$treegrid.treegrid('autoSizeColumn', field);
     }        
 }
I need to use the autoSizeColumn just once after laoding the tree root. (I am sure all the other data will fit the column width of the tree root)

Unfortunately I see that the library, after calling this.$treegrid.treegrid('autoSizeColumn', field), starts recalculating the columns width every time I expand a tree node.
I can say this because I see the method onResizeColumn: function(field, width) called every time I expand the node.

Is there a way for make the library to stop the auto column resize?

Thanks a lot.



Title: Re: [treegrid] autoSizeColumn just one time and not every LoadData
Post by: stworthy on April 07, 2014, 07:13:17 AM
To disable auto sizing a column, please set 'auto' property of the column to false. So your code looks like this.
Code:
var fields = this.$treegrid.treegrid('getColumnFields');  
for(var i=0; i<fields.length; i++){ 
var field = fields[i];             
this.$treegrid.treegrid('autoSizeColumn', field);
this.$treegrid.treegrid('getColumnOption', field).auto = false;
}        


Title: Re: [treegrid] autoSizeColumn just one time and not every LoadData
Post by: Overwhelmer on April 07, 2014, 08:40:20 AM
Thanks, it works!