-
3 Nov 2011 11:05 AM #11
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
3 Nov 2011 11:06 AM #12
Hi all,
Well, after testing some cases, I'm really not liking this new behavior in Ext.override('...', {...});, maybe I'm still missing something,
For example, in 4.1, I have a few overrides like this one:
but when Ext.layout.Context.runLayout runs, it calls layout.calculate(ownerContext), and, for a fit layout, the original calculate function is called instead of the override and thus it's giving me:Code:Ext.override('Ext.layout.container.Fit', { calculate: function (ownerContext) { var me = this, childItems = ownerContext.childItems, /* begin workaround */ //length = childItems.length, length = childItems !== undefined ? childItems.length : 0, /* end workaround */ targetSize = me.getContainerSize(ownerContext), contentSize = { width: 0, height: 0 }, i; for (i = 0; i < length; ++i) { me.fitItem(ownerContext, childItems[i], targetSize, contentSize); } if (!ownerContext.setContentSize(contentSize.width, contentSize.height)) { me.done = false; } } });
"Uncaught TypeError: Cannot read property 'length' of undefined"... (This error happens when there is a panel without child items, just using the html: property, I can report it in another post if it helps)
I understand and see the value of being able to have partial definitions of classes (coming from a .net world where partial classes are used somewhat widely), but maybe using another name instead of override, and let override do what the name suggest...
Thanks again
-
3 Nov 2011 11:07 AM #13Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Nov 2011 11:09 AM #14
Last edited by mitchellsimoens; 3 Nov 2011 at 11:09 AM. Reason: Let me fix that missing ']' for you :D
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
3 Nov 2011 11:15 AM #15
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
3 Nov 2011 11:20 AM #16
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
3 Nov 2011 11:33 AM #17
Yep, I know that workaround should not be needed, but I'm doing those overrides so I can test the 4.1.
I've used a few overrides for fixing problems that I got in 3.x, then in 4.0 and for sure, somewhere in the future I'd need some overrides to fix bugs until they are fixed in new releases (hopefully we'll be getting access to the 4.1 svn/git branch soon), so I need to find a reliable way to override some methods in ExtJS >= 4.1.
I've tried modifying directly ext-all-dev and they let me use my app with a few quirks here and there, but no errors, and I'm very pleased with the performance improvements, but obviously this method shouldn't be used....
I've tried doing the old school "Ext.layout.container.Fit.prototype.calculate = function (ownerContext) { ... };" for all my overrides, and although no error is raised, the app is not rendering as it is if I do the changes directly in ext-all-dev.... gotta investigate more why.
So, that's why I'm raising this issue about Ext.override(''..", {..}); these kind of overrides worked on 3.x and 4.0, so, I'm trying to find a way to be able to override core methods reliably.
-
3 Nov 2011 11:40 AM #18
Hello Don, thanks for your response,
Yup, in my tests, the override doesn't seems to be called, so that's the part I'm not liking (as I'm guessing more changes where done to that behavior, but maybe I'm wrong - I've not checked the core code to verify it -), I've no problem with the callParent change...
My override isn't getting called (tried some console.log) when the runLayout calls layout.calculate(....) as it calls the overridden original method...
-
3 Nov 2011 11:49 AM #19
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
3 Nov 2011 11:58 AM #20
The form you have should work in both 4.0 and 4.1, give or take using the string class name. You could try removing the quotes on the class name you are overriding.
You could try (in 4.1 only):
With appropriate namespaces and pathing of course.PHP Code:Ext.define('My.patch.Fit', {
override: 'Ext.layout.container.Fit',
calculate: function () {
...
}
});
//--- in your app:
{
layout: 'fit',
requires: 'My.patch.Fit'
}

This is a big part of why Ext.define/override was added in 4.1: to help manage overrides and when they are included in a build and when they can be (safely) applied to their target class.
Hope this helps!Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"



Reply With Quote