Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJS-7052
in
4.1.3.
-
Ext JS Premium Member
4.1.1: ownerCt or floatParent is no longer set for Button Menu
After we upgraded from 4.0.2a to 4.1.1, we noticed that "ownerCt" and "floatParent" are both undefined for a Menu under a Button. One of them used to be set to the owner button before the upgrade.
With some debugging, we found the "ownerButton" property of the menu is set to the owner Button, however, this ownerButton is not documented anywhere.
Is it a bug that ownerCt and floatParent not getting set for Button Menu? Otherwise, is there a supported way to access the owner Button from a Menu?
- Tested Browser: Chrome (Windows)
-
Certainly looks like it's been changed on purpose, we'll review it.
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
-
See here.
Now need to use getBubbleTarget, e.g:
Code:
/**
* Retrieves the parent control for the specified menu.
* In most cases this will be the button that was used to launch the menu.
* @param {Object} menu The menu whose parent to determine.
* @return {Object} The parent control for the menu, or undefined if not found.
*/
getTopMenusParent: function(menu) {
var parent = undefined;
if (menu) {
// Go up until we do not have a parentMenu, in case we are on a menus sub-menu.
while (menu.parentMenu) {
menu = menu.parentMenu;
}
parent = menu.getBubbleTarget();
}
return parent;
}
-
The recommended way is the up() method.
http://docs.sencha.com/ext-js/4-1/#!...nent-method-up
There is not an actual container->child ownership relationship there, so the up method hides these differences. There are quite a few places where there is a definite hierarchy, but it is not container->child. For example a column menu goes up() to the column header component.
I think maybe a note attached to the ownerCt property describing and linking to the up() method would be good.