GeoExt extends Ext JS, a rich library of web UI widgets and helper classes. Using GeoExt requires a working knowledge of Ext’s idioms. This tutorial provides a quick overview of core Ext concepts.
To start using Ext, you will first have to download it. For more complete instructions about how configure a web page to use Ext, you can check the GeoExt QuickStart tutorial.
When you download Ext, you also get their excellent Examples and API Documentation, which you can also look at on-line for education and reference.
In order to get Ext running on a page you will need to have something like the following in the <head> of an HTML page in a directory that is published by your web server.
<script src="ext-3.3.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="ext-3.3.1/ext-all.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="ext-3.3.1/resources/css/ext-all.css"></link>
This will load the code and styles for Ext. Change the paths according to where you have put the Ext files.
When writing Ext code, most of what you will be doing is instantiating classes with constructors that takes a single object–its configuration object–as an argument. This snippet demonstrates this coding pattern:
Ext.onReady(function(){
var myPanel = new Ext.Panel({
title: 'Hello World!',
html: '<i>Hello World!</i> Please enjoy this primer on Ext!',
collapsible: true,
width:300,
renderTo: 'panelDiv'
});
});
There are a few things to note about this example:
Ext makes it easy to separate out your UI into logical blocks. Most often you will be using one or more nested Containers. The Ext.Panel built above is the most common kind of container. You can nest panels using the items property. For example:
Ext.onReady(function(){
var myPanel = new Ext.Panel({
title: 'Top level',
layout: 'border',
items: [{
xtype:'panel',
title:'Sub1',
html:'Contents of sub panel 1',
region: 'east'
},{
xtype:'panel',
title: 'Sub2',
html:'Contents of sub panel 2',
region: 'center'
}],
width:300,
height:200,
renderTo:'panelDiv'
});
});
This code introduces some new concepts:
Ext provides a variety of other layouts, including a Tab layout and a Wizard layout. The best way to explore these layouts is using the Ext Layout Browser , which demonstrates each layout and provides sample code.