PDA

View Full Version : Grid Expander: Grow rather then scroll



siberian
4 Jan 2010, 10:10 PM
I have a grid with an Expander.

When I expand I'd like to have the grid window resize (grow) rather then have the grid start scrolling.

Is this possible?

See attached image for a screenshot and markup of what I am looking to accomplish.

My problem is that with the scroll my widget that expands (detail view) goes beneath the view portal and it angers my UI guy.

You don't want to anger the Ui guy.

Arno.Nyhm
5 Jan 2010, 9:06 AM
i see the RowExpander fire this events so you can listen to the events Events.Expand and Events.Collapse and fix the height of the grid...

siberian
6 Jan 2010, 10:37 AM
Thanks, this did it for me. I'm still fiddling with the pixel height but overall the solution works. What was breaking for me was that fact that my RootPanel was embedding everything in a viewport so the browser would not scroll past the viewport and thus the grid dropped off the bottom.

Moving RootPanel to a normal layout container resolved that and I am in business.

For future generations it looks like the below. Note that in this example my heights are hardcoded, in the final code they are dynamic based on actual container sizes but this gets the point across. On the collapse I check to see if the panel is back to its base size (300) so I don't contract more then I need to. On expansion I only expand the differential between the new panel and the remaining space.



grid.addListener(Events.CellClick, new Listener<GridEvent>() {
public void handleEvent(GridEvent gridEvent) {
if (gridEvent.getColIndex() == 0 && gridEvent.getTarget(".x-grid3-row-expanded", 7) != null) {
if((grid.getHeight()+178) > cp.getHeight()){
int newHeight = grid.getHeight() + ( 178-(cp.getHeight()-grid.getHeight()) );
cp.setHeight(newHeight);
}
} else if (gridEvent.getColIndex() == 0 && gridEvent.getTarget(".x-grid3-row-collapsed", 7) != null) {
int newHeight = 300;
if((grid.getHeight() - 178) > 300){
newHeight = grid.getHeight() - 178;
}
cp.setHeight(newHeight);
}
}
});

Arno.Nyhm
7 Jan 2010, 7:18 AM
thanks for the solution.

but with Events.Expand it is not working? because i see the rowexpander fire this events...