View Full Version : How to know when doLayout finishes

26 Feb 2010, 7:45 PM
I have a Portal with three columns. The middle column is hidden. The other two columns have columnWidth set to 0.5. I need to add a new Portlet into the middle column(which is hidden) and make the column visible. After this, I also need to resize all three columns to columnWidth = 0.33. To make this last step work I need to call myPortal.doLayout(false). Calling doLayout() on each column won't resize all three columns.

However, I always got the wrong result: the new Portlet always got inserted into the third column instead of the middle column. If I do not call myPortal.doLayout(false/true), the new Portlet will get inserted correctly into the middle column. However, I cannot avoid calling myPortal.doLayout(false/true) because I need to resize all three columns' width to 0.33.

I do not know what myPortal.doLayout(false/true) did that caused the problem. I am thinking about experimenting a second solution, but in order to do this, I need to know when the doLayout() process finish. Please advise.

My second solution is about swapping the order of steps to do the followings instead:
1- Make middle column visible.
2- Set all three columns's width to 0.33
3- Call myPortal.doLayout(false/true)
4- When myPortal.doLayout() finish, insert the new Portlet into the middle column and call middleColumn.doLayout();

Any advice is greatly appreciated.

27 Feb 2010, 4:17 AM
I must admit I don't completely understand your question, is it not the afterlayout event you should be looking at?

2 Mar 2010, 1:02 AM
Thanks for replying to my question.
Yes. "afterlayout" is the event I was looking for. I found out about it shortly after posting my question.

The solution I used to fix the problem described in my first post is that I had to use (function(){//...}).defer(2000, this) because "doLayout" call on parent component ends up calling "doLayout" on each child component and so on...We actually do not know when the doLayout of grand grand grand child component finishes. I hate using "defer" thing, but I had no choice in this case. If anybody knows a better solution, please share. Thanks.