Ext is a client-side, JavaScript framework for building web applications. In early 2006, Jack Slocum began working on a set of extension utilities for the Yahoo! User Interface (YUI) library. These extensions were quickly organized into an independent library of code and distributed under the name "yui-ext." In the fall of 2006, Jack released version .33 of yui-ext, which turned out to be the final version of the code under that name (and under the open source BSD license). By the end of the year, the library had gained so much in popularity that the name was changed simply to Ext, a reflection of its maturity and independence as a layout:'fit',framework. A company was formed in early 2007, and Ext is now dual-licensed under the GPL and a commercial license. The library officially hit version 1.0 on April 1, 2007.
Ext has a dual-license model. We offer an open source LGPL license along with a per-developer, royalty-free commercial license. Details can be found on our licensing page. Please note that our licensing does NOT provide any support or SVN access — for support options (including premium forum access, SVN access, email support and more) please take a look at our support page.
As a client-side framework, Ext can run against any server platform that can process POST requests and return structured data. Common choices include PHP, Java, .NET and many more. There are server-side frameworks available for most popular platforms that will make your life much easier when programming under the AJAX application model that Ext uses.
Up until version 1.0.1a, Ext required one of the following base libraries to be included: YUI, jQuery or Prototype/Script.aculo.us. Ext contains adapters that provide some of the basic plumbing utilities from those libraries, including Ajax support, animation, DOM manipulation, event handling, etc. Beginning with version 1.1, Ext includes a native Ext adapter, so the external libraries are no longer required.
Your choice of base libraries/adapters will most likely be driven by whether or not you already use an external library for something that Ext does not provide. For example, YUI includes some components like a history manager that Ext does not provide. In that case, you may want to include the YUI adapter. Or if you have already invested in a library in an existing application, but want to add Ext to it, you might consider the adapter for that library to keep the code size smaller. If you do not have either of those needs, the Ext adapter will provide the smallest footprint and most compatible support. Note: since the non-Ext adapters rely on external libraries, not all functions are guaranteed to be supported or bug-free.
This same list is also included with the Ext download in the root folder in a file called INCLUDE_ORDER.txt. All Ext adapter files (and ext-base.js) can be found in the \adapters folder in the release. The libraries are listed in order of recommendation. Note: At the present time, Prototype/Scriptaculous support should still be considered experimental as there are several known bugs and unsupported functions that can cause problems with Ext.
| Base Library | Include Order | Get Library |
|---|---|---|
| Ext Standalone | ext-base.js ext-all.js (or your choice of files) | http://www.extjs.com/download |
| Yahoo! UI (.12+) | yui-utilities.js (or your choice of YUI base files) ext-yui-adapter.js ext-all.js (or your choice of files) | http://developer.yahoo.com/yui/ |
| jQuery (1.1+) | jquery.js jquery-plugins.js // required jQuery plugins ext-jquery-adapter.js ext-all.js (or your choice of files) | http://jquery.com/ http://docs.jquery.com/Plugins |
| Prototype (1.5+) / Scriptaculous (1.7+) | prototype.js scriptaculous.js?load=effects (or whatever you want to load) ext-prototype-adapter.js ext-all.js (or your choice of files) | http://www.prototypejs.org/ http://script.aculo.us/ |
Note for YUI users: Ext already includes yui-utilities.js, which is a convenience file containing the base YUI utilities (YAHOO, Event, Dom, Animation and Connection). If you do not otherwise use YUI, this should be sufficient for your needs — it is not guaranteed to be up-to-date with the most current release of YUI, but it is guaranteed to work correctly with Ext. If you need something in the most current release of YUI, you may need to supply your own copy of the utility files that you need.
As specified here: Regarding SVN. Access to the Ext SVN (Subversion) repository is available to support subscribers only. The only source code that you can download is the latest code officialy released by the ExtJS team and is accessible from here.
Whether you're a seasoned JavaScript programmer or just starting out, the cause of problems can often be hard to track down. Here is a checklist you can work through when your code is not working as you expect it to work:
var myExample = function() { return { foo: 'bar', boo: 'far' } };
Be sure the opening curly brace is on the same line:
var myExample = function() { return { foo: 'bar', boo: 'far' } };
If not, it'll be a pain to debug as trying to reference 'myExample.foo' or 'myExample.boo' will result in an error that they're undefined even though it seems they clearly are.
Configure your GridView with the following options:
onLoad: Ext.emptyFn, listeners: { beforerefresh: function(v) { v.scrollTop = v.scroller.dom.scrollTop; v.scrollHeight = v.scroller.dom.scrollHeight; }, refresh: function(v) { v.scroller.dom.scrollTop = v.scrollTop + (v.scrollTop == 0 ? 0 : v.scroller.dom.scrollHeight - v.scrollHeight); } }
Thanks to dj [1]
Your HTML code, for example here a button
<input type="submit" id="btnLaunch" value="Lancer" name="btnLaunch"/>
is NOT an Ext.Button.
An Ext.Button looks quite differently in HTML e.g. this is a button of one of my ExtJS applications
<table cellspacing="0" cellpadding="0" border="0" class="x-btn-wrap x-btn x-btn-text-icon" id="ext-comp-1169" style="width: auto;"><tbody><tr><td class="x-btn-left"><i> </i></td><td class="x-btn-center"><em unselectable="on"><button type="button" class="x-btn-text" id="ext-gen138" style="background-image: url(/img/settings.gif);">Profile</button></em></td><td class="x-btn-right"><i> </i></td></tr></tbody></table>
Ext.Button needs all those extra HTML to do it's work. Your normal HTML submit input element (not even a HTML button element ) can only be accessed as Ext.Element:
Ext.get('btnLaunch').dom.value = 'a test';
Ext.getCmp() can only get you the button object if you created that somewhere else.
E.g. I create the button mentioned above with
new Ext.Button({ id:'settings-button', text: 'Profile', cls: "x-btn-text-icon", icon: MMEPR.baseUrl + "img/settings.gif", handler: this.showSettings, scope: this, renderTo: container });
and can later get a reference to it with
var button = Ext.getCmp('settings-button');
Ajax requests using the regular XMLHttpRequest mechanism can only be sent to a server in the same domain as the page was served from.
This is known as the Same Origin Policy
This behavior can be achieved one of two ways. The first method uses TabPanels' tabchange event to force a fresh of any newly selected tab item:
new Ext.TabPanel({ region:'center', deferredRender:false, activeTab:0, defaults:{autoScroll:true}, listeners: { tabchange: function(tp,newTab){ var um = newTab.getUpdater(); if(um) um.refresh(); } }, items:[{ title: 'Refreshed Panel', autoLoad:{url:'dynamicContent.php'}, }] });
The second method registers the activate event on individual tab panels:
new Ext.TabPanel({ region:'center', deferredRender:false, activeTab:0, defaults:{autoScroll:true}, items:[{ title: 'Refreshed Panel', autoLoad:{url:'dynamicContent.php'}, listeners:{ activate : function(panel){ panel.getUpdater().refresh(); } } }] });
See http://extjs.com/forum/showthread.php?t=11698#2 or http://extjs.com/forum/showthread.php?t=6710#2
Usually, this question means that different parameters need to be passed to the same server script. The answer is Do not embed parameters in the DataProxy's URL
To add parameters to a Grid's server requests add a listener for its Proxy's beforeload event:
var proxy = new Ext.data.HttpProxy({ url: '/DoSearch.php' }); // Add the HTTP parameter searchTerm to the request proxy.on('beforeload', function(p, params) { params.searchTerm = searchValue; });
Add a listener for the Grid's cellclick event.
The listener is passed the row and column indexed clicked on. The column index may be used to determine which field was clicked on (Columns may be reordered by the user so using the column index as the field index is unsafe)
A cellclick event handler must find the relevant information like this:
function(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record for the row var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name for the column var data = record.get(fieldName); }
You can use a function of your own to add a CSS class name of your own choosing to a Grid row depending upon the data in the underlying Record object.
Override the getRowClass function in the Grid's View with your function and return a class name string.
See this forum post.
When using remote data (through an HttpProxy, or a ScriptTagProxy) Store.load() is asynchronous. It returns immediately after the request is sent to the server without blocking.
To perform postprocessing of returned data, use a callback to the load call, or add listeners to the Store's "load" and "loadexception"(most problems will be indicated here) events.
Script execution in Ajax-loaded markup is not enabled by default for performance reasons. Script elements are extracted and executed optionally based upon either the global configuration option Ext.Updater.defaults.loadScripts, or options passed into the Updater.update method and the Element.update method.
Ext.get returns an Ext.Element object which is an abstraction of an HTML element object containing utility methods to perform DOM manipulation. It does not retrieve Components (e.g. Panels, Grids, form Fields, etc) by their id. To retrieve Components use Ext.getCmp.
A Tree Node with no children is a leaf node. If you want a node to always have a certain icon, use the iconCls attribute to give it a class name eg:
myNode.appendChild(new AsyncTreeNode({ text: "A folder", iconCls: "folder" });
Then specify appropriate CSS rules, eg:
.x-tree-node img.folder, .x-tree-node-collapsed img.folder{ background: url("../images/default/tree/folder.gif"); } .x-tree-node-expanded img.folder { background: url("../images/default/tree/folder-open.gif"); }
This almost always means that you are missing one of your include files (or a path is invalid), or the include files are not in the proper order. Each include file depends on the previous one, and if anything in the chain is missing, an error will occur. This message simply means that Ext was never properly loaded, and the first piece of application code that calls into Ext will get this error.
This could also mean that the type attribute on one or more of your script tags is incorrectly set. For example:
<script type="text/javasscript" src="/somepath.js"></script>
<script type="text/javascript" src="/somepath.js"></script>
The first tag will not correctly load the javascript even if "somepath.js" is the correct location of your script file. (Notice the mis-spelling of javascript in the type attribute). The second tag will work just fine.
It means that XX is not a valid object reference. This error is commonly caused by a reference to a non-existent (or non-available) element for which the specified id does not exist in the DOM. There are many cases in which you can specify an element by id. For example:
// constructors: var tb = new Ext.Toolbar('toolbar'); // creating Element references: var saveBtn = Ext.get('save-button');
The string passed must be the id attribute of a valid HTML element, e.g.
<div id="toolbar"></div> <input id="save-button" type="button" value="Save" />
If an element with such an id does not exist in your document, has not yet been created, or if the code is executed before the DOM has been fully loaded (tip: always use Ext.onReady when your code depends on the availability of any DOM elements), then you will end up with an undefined variable that will throw this error message the first time you attempt to access it as an object.
Call doLayout() on the container after you add any component to it.
Set layoutOnTabChange: true in your Tab Panel config.
Somewhere at the top of your code you should place a line like the following one, that tells Ext where to find the empty image it needs for some widgets (preferably from your own server/domain). Modify the URL as needed:
This cannot be preset to a value that exists on your server. We cannot predict where you will place your image directory!
Ext.BLANK_IMAGE_URL = '/images/ext/resources/images/default/s.gif'; // Ext 2.0 Ext.BLANK_IMAGE_URL = '/images/ext/resources/images/aero/s.gif'; // Ext 1.1
You can also read about it in the documentation.
You might have an extra comma somewhere in your code that causes Internet Explorer to stop parsing the code correctly. The most common symptom is that your code works without any errors in other browsers, but not in IE. You can read more discussion about this issue in the forums. Here is an example of what to watch out for:
testFunc = function() { return { titlebar: true, collapsible: true, // <--- BOOM goes the comma! :D } }
or:
configOption: [ arrayEl1, ArrayEl2, // <-- Will NOT blow up here, but creates an extra element ]
This adds an extra element of value undefined to the end of the Array, and some Components which process Arrays may be adversely affected by this.
A helpful tool to use is JSLint, which parses and verifies the validity of your code. It's very handy in general, and will catch this problem easily.
Another way is to run the page in Opera with the Error Console set to display Javascript errors. This often pinpoints problem areas of code much better than IE.
If you have a minified version of your code, you can search their for ",]" or ",}", this way you can find some of the "extra commas". You can also search in your "not minified" code with regular expressions like ,[\s ]*\] .
It's likely that the z-index of the menu or other element needs to be higher in the YUI CSS — YAHOO! sets them very low by default (e.g. 1). Also, you might try rendering your YUI component to the body element if appropriate. Z-index can only override other elements within the same container. Rendering to the body guarantees that a given element's z-index will always be respected.
Probably one of the best tool combinations for debugging your application is to use the Mozilla Firefox browser with the Firebug addon and optionally the Web Developer addon. Another very useful tool is Venkman - the JS debugger.
If you're using Microsoft Internet Explorer you can try out the Microsoft Developer Toolbar plugin. There is also the DebugBar which is free for personal use.
For the Opera browser you can use the Opera Developer Tools or the alternative Web Developer Toolbar & Menu for Opera.
Safari users can use the Web Inspector to get an overview of the page or enable Debug menu in the browser.
If you're getting that annoying security warning that asks you if you want to download insecure items in IE over SSL, don't fret. You just have to remember to set your BLANK_IMG_URL to the local version of s.gif. See above section 3.3 My code links to extjs.com/s.gif .
Rarely, there is an issue with Apache cutting off lengthy files — ext-all.js can get cut off mid-stream, which can lead to strange errors over HTTP while things work just fine served locally. There are various potential causes. See this forum thread for additional discussion and potential solutions.