Ext Js
Ext js is a cross browser JavaScript library for building rich internet application. You can build a high performance user interface with easy to use API. Its object-oriented design patterns influence the relationship and interactions between objects
Creating a application using Ext 2.0
While creating a application there should always be a directory structure. There is a Document Root directory in the server and all other folder relative to it.
Recommended directory structure
./CSS (optionally link)
./ext (link)
./img (link)
./js
Index.html
Link means a link pointing to a real directory where files are stored.
The advantage is that if you have new version of ext or some other files you have to change just the link to point there without changing anything in your application.
- css will hold all stylesheets.
- ext link to Ext JS Library tree.
- img link to your images. It can contain icons subdirectory as well.
- js will hold all javascript files the application is composed of.
- index.html HTML file that is an entry point of your application. You can have different name for this file but there is one application entry point/file.
- optionally you can create a directory or a link for your server side part of the application (like if you are using aspx file it may be ./aspx)
index.html
index.html should link defined in the head sestion for following css and javascript file
./ext/resources/css/ext-all.css
./css/application.css
./ext/adapter/ext/ext-Base.js
./ext/ext-all-debug.js
./application.js
Index.html has all the link defined for css file and javascript file that is required to built a ext application.
ext-all-debug.js include the entire Ext framework. Use ext-all-debug.js for development and ext-all.js for production purpose.
Js/application.js
Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';
Ext.ns('Application');
// application main entry point
Ext.onReady(function() {
//code here
});
- Ext.BLANK_IMAGE_URL point to a image file that is used by Ext as an image hoder and if it point to invalid location you can get various rendering problem.
- You may also need to create a new global object variable for your application (here it is Application).
- Ext.onReady is the main application point. The place where you write your code for application.
css/application.css
This file will contain all css stylesheet.
Using Pre-configured classes
The best approach to write a Ext application is to write extension classes of Ext component that have all configuration option.You have to just pass the configuration object for that.
An example for creating a panel to be used as an application window.
//application.js
var win = new Ext.Window({
title:'Personnel'
,widht:600
,height:400
,items:{xtype:'personnelgrid'}
});
win.show();
Organizing pre-configured calsses
The above code create a javascript object .It should be written in a seprate file(/js/filename.js) and included in index.html as
Production system
For production purpose you do not require debug version of Ext library.
Include
- ext-all.js
- app-all.js and
- application.js (your javascript file application code)
Labels: extjs