View Full Version : [CLOSED] Force layout of Button's children

Oct 23, 2012, 3:57 PM
Hi folks, i would like to know whether it's possible to force the redering of button's menu. In the following example, the Menu's AfterRender event (line 12) is just fired when the button _btn is clicked.

To overcome this issue it's possible to call Menu's doAutoRender method (Please uncomment from line 16 to 18) after button's rendering, but i'm not sure that it's the best approach to accomplish my needs.

What you think about it?

Thanks in advance.

<ext:Toolbar ID="Toolbar1" runat="server" Width="500">
<ext:Button ID="_btn" runat="server" Text="Click Me" Icon="Application">
<ext:Menu ID="_mnl" runat="server">
<ext:MenuItem Text="Menu 1" Icon="Accept" runat="server" />
<ext:MenuItem Text="Menu 1" Icon="Accept" runat="server" />
<ext:MenuItem Text="Menu 1" Icon="Accept" runat="server" />
<AfterRender Handler="alert('Menu was rendered');" />
<AfterRender Handler="item.menu.doAutoRender();" />

Oct 23, 2012, 8:28 PM
Hi Raphael,

I think your approach is good.

Oct 23, 2012, 9:38 PM
Button's showMenu (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.button.Button-method-showMenu) calls Menu's showBy (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.menu.Menu-method-showBy) method, that calls Abstract Component's doAutoRender (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.AbstractComponent-method-doAutoRender) method, that calls the Render method. When the button is pressed, it will call Menu's showBy (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.menu.Menu-method-showBy) again, but the Button's children will not be rendered again because Render method makes the following validation:

if (!me.rendered && me.fireEvent('beforerender', me) !== false)

so, the button's children are not rendered twice

The "stack trace" is a little confusing, but in my opnion there is no performance leak, so i think that it's an acceptable approach.

Daniil, if you agree, please mark this thread as closed.

Thank you.

Oct 23, 2012, 10:49 PM
Can you clarify why do you need it (force menu rendering )?
Do you need instance of menu? Or menu contains fields which must be submitted?

Oct 24, 2012, 12:47 PM
I have a GridPanel within Button's Menu. it must be populated when its rendering is complete. So i populate it when AfterRender event is fired but it's just fired when the button is clicked by the first time, otherwise the GridPanel does not exist.

Oct 24, 2012, 2:36 PM

#1 http://forums.ext.net/showthread.php?10205-More-Information-Required

Oct 26, 2012, 6:53 PM
Hi Raphael,

Please clarify is the issue still actual?

Oct 26, 2012, 8:22 PM
i am gonna prepare an example. please wait until monday.

Oct 29, 2012, 9:51 AM
Sure, no problem. Thanks.


Marked closed. Please feel free to update the thread with a sample.