-
31 Jan 2013 5:01 AM #1
Unanswered: Containers with CSS-driven layouts: how to make Ext get out of the way?
Unanswered: Containers with CSS-driven layouts: how to make Ext get out of the way?
I have an ExtJS application with highly customized appearance that is mostly defined by CSS. I have multiple forms throughout the app that are dynamically configured when they load records.
Without going into much detail, the structure of forms is quite typical:
As I noticed, I havethe appearance as well as dimensions for most elements (form fields and other child items) completely defined in CSS. This means:Code:form fieldset field field field ... fieldset field field ... fieldset ...- many elements have fixed sizes and I am ok about that. I have custom layout logic that places forms around the viewport area but forms themselves are not fluid: their widths are fixed and their heights are just naturally managed by the browser
- I only care about modern browsers. IE<8 is not supported. Even IE8 has basic support.
- component hierarchy (so child items have proper ownerCt and are present in the items collection of their parents) so that ComponentQuery, component event bubbling and some other things work properly
- containers rendering their children (just rendering! nothing beyond that)
Note that I recently upgraded from 4.0 to 4.1 and had really high hopes to see increased layout performance. I was really excited that now there's a re-enterable method Ext.AbstractComponent.suspendLayouts() that took place of the pathetic this.suspendLayout = true; which kept being overridden in Ext's base methods when I was doing complex operations on form load. But even after some tinkering around and finally making all the Layout run failed console logs go away, I didn't win as much milliseconds (form load time) as I had expected.
What I've done so far:- Set layout: 'auto' for my form panels, fieldsets and some other complex components.
The docs say:However, for some reason there's still a ton of things happening besides just rendering child items!The AutoLayout is the default layout manager delegated by Ext.container.Container to render any child Components when no layout is configured into a Container. AutoLayout provides only a passthrough of any layout calls to any child containers. - Set shrinkWrap: true; on all field components to eliminate the "Layout run failed" messages.
- by the way I didn't really get whether this property increases or decreases performance
- Setting componentLayout: 'auto'; on the form panel now breaks things so I commented it out
- In 4.0, the following override on field items and other form children noticably improved layout performance and prevented Ext's layout setting some unwanted inline styles:
getBodyNaturalWidth: function (){ return undefined; }
However, the method isn't used in 4.1 anymore.
Now I understand that Ext's layout system is a huge monster and, while defined separately in the codebase, it still appears to be tightly weaved into the component system and it's probably impossible to completely achieve what I'm trying to do without rewriting the whole framework but any kind input is highly appreciated.
I noticed that there have been tangential discussions before:- Control styles totally in external css file?
- Layout structure question
- HTML-focused DOM Layout for auto-height web applications (Ext 4.1)
Great thanks to all in advance!
-
4 Feb 2013 9:09 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
If you don't specify a layout on the container, it will use auto layout which doesn't do a whole lot. You should be able to do use CSS to lay things out for the most part.
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.
-
5 Feb 2013 3:22 AM #3
I am specifying layout: 'auto' on components. However a lot of stuff is still happening.
-
6 Feb 2013 1:02 AM #4
One of the things I am still struggling with is preventing Ext from setting width and height and other CSS properties to Panel's body element, this sometimes overrides my styles.
The manageHeight property looks like the one I need:
I set manageHeight to false, however, the body element still gets the following styles:When true, the dock component layout writes height information to the panel's DOM elements based on its shrink wrap height calculation. This ensures that the browser respects the calculated height. When false, the dock component layout will not write heights on the panel or its body element. In some simple layout cases, not writing the heights to the DOM may be desired because this allows the browser to respond to direct DOM manipulations (like animations).
The only effect that manageHeight seems to have is turning the left and top inline styles into margin-left and margin-top. Is that the intended behavior? Why doesn't it perform as described in the docs?Code:{ width: 320px; margin-left: 0px; margin-top: 0px; height: 380px; }
P.S. The componentLayout on my Panels is set to dock and I can't set it to auto since it breaks things.


Reply With Quote