|
2 år sedan | |
---|---|---|
.. | ||
README.js | 2 år sedan | |
README.md | 2 år sedan | |
icon.png | 2 år sedan |
Contents
\nThis guide is meant to assist developers migrating from Ext JS 4.0.x to 4.1. Our goal was to maintain API compatibility\nas much as possible, despite the scope of the changes we are making to address bugs and user feedback. However, some\nchanges were needed, which you need to consider in further Ext JS development.
\n\nIf you encounter issues related to these API changes, please post your issues directly to our community forum found\nhere. If you are a support subscriber, you can also file your\nissue through our support portal found here.
\n\nPrevious releases used the render
method to render all components in a top-down traversal. In 4.1, rendering is\nperformed in memory as markup which is then written to the DOM. This means that the render
method of child components\nis not called. It's recommended that code in the render
method be moved to either beforeRender
(new to 4.1) or\nafterRender
. For best performance, make style or add/removeCls
adjustments in beforeRender
so that these values\nare generated in the initial markup and not made to the DOM element as it would be in afterRender
.
Previous releases created the component's primary element (el
) when calling the parent class method. This is no longer\npossible because of bulk rendering. Any logic that was performed prior to calling the parent
method can be moved to\nthe new beforeRender
method
As part of bulk rendering, a renderTpl
now calls helper methods on the template instance to inject content and\ncontainer items. This can be best seen in the default renderTpl
for components and containers:
Code for components:
\n\nrenderTpl: '{%this.renderContent(out,values)%}'\n
\n\nCode for containers:
\n\nrenderTpl: '{%this.renderContainer(out,values)%}'\n
\n\nAs part of formalizing Ext.define/override
in Ext JS 4.1, it is now possible to name and require overrides just as\nyou would a normal class:
Ext.define('My.patch.Grid', {\n override: 'Ext.grid.Panel',\n foo: function () {\n this.callParent(); // calls Ext.grid.Panel.foo\n }\n});\n
\n\nThe above code in Ext JS 4.0 would have called the base class foo
method. You had to use the callOverridden
to\naccomplish the above. In Ext JS 4.1, to bypass the overriden method, you just need to use the following code:
Ext.define('My.patch.Grid', {\n override: 'Ext.grid.Panel',\n foo: function () {\n Ext.grid.Panel.superclass.foo.call(this);\n }\n});\n
\n\nIt is even possible for a class to require
its own overrides. This enables breaking up a large class into independent\nparts expressed as overrides (a better approach than AbstractFoo
and Foo
).
In previous releases, use of FocusManager
was inefficient. FocusManager
used to have to be pointed at a container\n(that is, it had to subscribe to the Container), and it would dig out all descendant components and add listeners to\nboth the descendants' elements and the descendant components themselves. It also had to monitor for adds and removes\nwithin that container tree.
In Ext JS 4.1, onFocus
and onBlur
template methods in AbstractComponent
are called on focus and blur of the\ncomponent's getFocusEl()
. This is part of a component’s natural functionality. Non-focusable components won't\nimplement getFocusEl
, and so they will not be part of the focus tree. Containers are focusable so that you can\nnavigate between and into them.
Now, FocusManager
hooks directly into AbstractComponent
template methods and hears what is being focused. Once it's\nenabled it globally tracks focus, and adds framing which follows focus, and allows navigation into the\ncontainer->component tree.
The doLayout and doComponentLayout methods have been modified. Their previous functionality has been combined into\nupdateLayout
. As a component author, these methods can no longer be overridden to perform a custom layout since they\nwill not be called internally as they used to be. Instead you can override afterComponentLayout
, which is given the\nnew size and old size as parameters, or you can respond to the resize event. Overriding afterComponentLayout
is a\npossible way of postprocessing a Component's structure after a layout. If you are writing a derived component, the\nmethod override should be preferred. Just be sure to use callParent
.
Note that the size of the component should not be changed by this method,since the size has been determined already. If\nthe size is changed again, this could lead to infinite recursion at worst (since afterComponentLayout
will be called\nagain) or just wrong layout.
In Ext JS 4.0, the config mechanism in Ext.define
would create getter
and setter
methods, but the default value\nwould bypass the setter. In Ext JS 4.1 (and Touch 2), config defaults are now passed to the setter method. This can\naffect the timing of the first call to the setter method, but it is needed because setters are designed to enable\ntransformation-on-set semantics.
The generated getter for a config property named “foo” looks like the following:
\n\ngetFoo: function () {\n if (!this._isFooInitialized) {\n this._isFooInitialized = true;\n this.setFoo(this.config.foo);\n }\n return this.foo; // or call user-provided getFoo method\n},\n
\n\nAnd the generated setter looks like this:
\n\nsetFoo: function (newValue) {\n var oldValue = this.foo;\n\n if (!this._isFooInitialized) {\n this._isFooInitialized = true;\n }\n\n this.applyFoo(newValue, oldValue);\n\n if (typeof newValue != ‘undefined’) {\n this.foo = newValue;\n if (newValue !== oldValue) {\n this.updateFoo(newValue, oldValue);\n }\n }\n}\n
\n\nIf there is no applyFoo
and/or updateFoo
method, these calls are simply skipped. It is best to provide custom\nimplementations of applyFoo
rather than a custom setFoo
so that the rest of the provided boilerplate is preserved.\nAlternatively, responding only to changes in the property is often ideal, so implementing updateFoo
may be better to\nignore setter calls that do not change the property.
A single record can belong to more than one store, especially in the case of a tree. The store
property on a model\nnow only references the first store. Use the stores
array to examine all stores.
In Ext JS 4.1, when you configure components with split: true
, Border layout inserts extra splitter components as\nsiblings of the current components. This simplifies Border and also allows enables it to dynamically modify regions.
To scroll an indeterminate sized dataset within a grid, simply configure the Store with
\n\nbuffered: true,\nautoLoad: true,\n
\n\nThe grid will scroll through the whole dataset using natural scrolling, but only using as many table rows as are\nnecessary to display the visible portion of the data with a small (configurable) leading and trailing zone to provide\nscrolling.
\n\nXTemplates now accept <tpl elseif>
and <tpl else>
tags between <tpl if>
and </tpl>
XTemplates now evaluate embedded script fragments as \"scriptlets\" using \"{% code %}\". The code is executed, but nothing\nis placed into the template’s output stream.
\n\nCertain Sencha-supplied Grid plugins and Features may now be used with lockable grids. The non-locked columns of a\nlockable grid may be edited using a row or cell editor. The grouping Features divide into two to work on both sides of\nthe lockable grid and stay synchronized.
\n\nSee the examples/grid/locking-group-summary-grid.html
example in your SDK for an example.
In previous versions of Ext JS, using the Ext.util.History class required you to manually add a form element to your\npage. This is no longer required. They will still be used if present, but it is best to remove them and allow the\nframework to generate what is required for the browser. The form that was required looked like this:
\n\n<form id=\"history-form\" class=\"x-hide-display\">\n <input type=\"hidden\" id=\"x-history-field\" />\n <iframe id=\"x-history-frame\"></iframe>\n</form>\n
\n"});