View Full Version : How to hide body of gridpanel?
experts
16 Apr 2012, 11:32 PM
My grid have some docked toolbars and i want to hide only grid body. I tried to hide like this:
mygrid.body.hide();
rows disappeared but container height not changed. So instead of grid rows I got empty space..So how collapse and expand gridpanel body?
Same question here if you want some points
http://stackoverflow.com/q/10137810/486349
vietits
17 Apr 2012, 12:43 AM
Try this
grid.setHeight(grid.getHeight() - grid.getView().getHeight());
experts
17 Apr 2012, 1:02 AM
I have tried this it works when I need hide but when I try to show it body loses height so I cannot restore it.
console.log(me.getView().getHeight(),'before');
me.setHeight(me.getHeight() - me.getView().getHeight());
me.setHeight(me.getHeight() + me.getView().getHeight());
console.log(me.getView().getHeight(),'after');
and result was:
161 before
104 after
Maybe I should save height somewhere where would best place? there is not one grid those grids created dynamically
vietits
17 Apr 2012, 1:14 AM
You should save the original grid height if you want to expand it again. Ex:
function collapse(grid){
if(!grid.originalHeight) grid.originalHeight = grid.getHeight();
grid.setHeight(grid.getHeight() - grid.getView().getHeight);
}
function expand(grid){
if(grid.originalHeight) grid.setHeight(grid.originalHeight);
}
experts
17 Apr 2012, 3:41 AM
Almost work just why it disappears after collapse, expand, collapse.
after some debug maybe I got why. that's because grid.body becomes to tall..
function collapse(grid){
console.log(grid.getView().getHeight(), grid.getHeight(),'before collapse');
if(!grid.originalHeight) grid.originalHeight = grid.getHeight();
grid.setHeight(grid.getHeight() - grid.getView().getHeight());
console.log(grid.getView().getHeight(), grid.getHeight(),'after collapse');
}
function expand(grid) {
console.log(grid.getView().getHeight(), grid.getHeight(),'before expand');
if(grid.originalHeight) grid.setHeight(grid.originalHeight);
console.log(grid.getView().getHeight(), grid.getHeight(),'after expand');
}
debug:
161 215 before collapse
52 54 after collapse
52 54 before expand
213 215 after expand
213 215 before collapse
213 2 after collapse
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.