EasyUI Forum
May 20, 2024, 07:59:58 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] autoSizeColumn just one time and not every LoadData  (Read 7139 times)
Overwhelmer
Newbie
*
Posts: 6


View Profile Email
« 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.

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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;
}        
Logged
Overwhelmer
Newbie
*
Posts: 6


View Profile Email
« Reply #2 on: April 07, 2014, 08:40:20 AM »

Thanks, it works!
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!