PDA

View Full Version : Borderlayout resize listener?



kjordan
21 Dec 2006, 10:36 PM
Is there any way to have a function called when the contentpanels of a borderlayout are resized (i.e. when the split bar has been dragged)? I want to base the size of a grid on the size of the contentpanel it's in (take up 100% of it always, no pixel more and no pixel less ;)) but I can't seem to find any listener for this so I can do that.

kjordan
22 Dec 2006, 12:49 AM
Found ContentPanel.setSize which seems to work fine (although it's strange that I didn't see this anywhere in the docs).

Animal
22 Dec 2006, 12:51 AM
http://www.yui-ext.com/deploy/yui-ext/docs/

Look at the Public Events of the BorderLayout class.

But to make a Grid autosize to the Region, render it into a GridPanel, not a ContentPanel.

mdissel
22 Dec 2006, 3:24 AM
Indeed.. The grid will be autosized when used in a GridPanel, but it would also be usefull if the grid has resize event...

Thanks

Marco

tryanDLS
22 Dec 2006, 9:07 AM
That's the point of a gridpanel. A grid is a fixed size - that's why you have to specify the container size.

If don't want to use a GP, you could possibly put a grid in a Resizable, and let that pass a new size to the grid.

kjordan
22 Dec 2006, 10:08 AM
Well, I suppose it works if I just want the grid resized to match, but I also want to reset the number of rows visible based on the size so I can make it so it doesn't have a scrollbar since I'm using paging. Overriding setSize for a grid panel pretty much breaks it. blayout.on('regionresized',function(region,newSize) { /*blah*/ }); doesn't seem to get called either on a panel resize for some reason. I may have to go back to just a content panel since I could use that without a problem.

mdissel
22 Dec 2006, 12:33 PM
Well, I suppose it works if I just want the grid resized to match, but I also want to reset the number of rows visible based on the size so

I want the same, so that's why i asketd for a resize event on the grid that's called when the grid is resized.. There's already a MonitorWindowResize so that can easily raise the resize event to the 'outside world'.

Thanks
Marco

Animal
22 Dec 2006, 1:23 PM
Render the grid into a GridPanel, and subscribe to the "regionresized" event of the Region you put it in: http://www.yui-ext.com/deploy/yui-ext/docs/output/YAHOO.ext.BorderLayout.html#event-regionresized