SlideShare ist ein Scribd-Unternehmen logo
1 von 43
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
A powerful javascript framework
by
Vincenzo Ferrari
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
Ext.Loader
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.Loader is the heart of the new dynamic dependency loading
capability in Ext JS 4+. It is most commonly used via the Ext.require
shorthand. Ext.Loader supports both asynchronous and synchronous
loading approaches.
Asynchronous Loading
Advantages
Cross-domain
No web server needed
Best possible debugging
Disadvantages
Dependencies need to be specified before-hand
Synchronous Loading on Demand
Advantages
There's no need to specify dependencies before-hand
Disadvantages
Not as good debugging experience
Must be from the same domain due to XHR restriction
Need a web server
Hybrid Solution
It has all the advantages
combined from
asynchronous and
synchronous loading
Ext.Loader – Sync
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.create & Ext.widget
// Instead of new Ext.window.Window({...});
Ext.create('widget.window', { ... });
// Same as above, using full class name instead of alias
Ext.create('Ext.window.Window', {});
// Same as above, all you need is the traditional `xtype`
Ext.widget('window', {});
Behind the scene, Ext.ClassManager will automatically check whether the given
class name / alias has already existed on the page. If it's not, Ext.Loader will
immediately switch itself to synchronous mode and automatic load the given class
and all its dependencies.
Ext.Loader – Async
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.require
// Syntax
Ext.require({String/Array} expressions);
// Single alias
Ext.require('widget.window');
// Single class name
Ext.require('Ext.window.Window');
// Multiple aliases / class names mix
Ext.require(['widget.window',
'layout.border', 'Ext.data.Connection']);
// Wildcards
Ext.require(['widget.*', 'layout.*',
'Ext.data.*']);
Ext.exclude
// Syntax: Note that it must be in this
chaining format.
Ext.exclude({String/Array} expressions)
.require({String/Array} expressions);
// Include everything except Ext.data.*
Ext.exclude('Ext.data.*').require('*');
// Include all widgets except
widget.checkbox*,which will match
widget.checkbox, widget.checkboxfield,
widget.checkboxgroup, etc.
Ext.exclude('widget.checkbox*').require('wi
dget.*');
Ext.Loader – Hybrid
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.create + Ext.require
// Enable the dynamic dependency loading feature
Ext.Loader.setConfig ({
enabled: true
});
Ext.require (['Ext.window.Window']);
// Ready when all dependecies has loaded
Ext.onReady(function () {
var window = Ext.create ('Ext.window.Window', {
title: 'My Window',
width: 300,
height: 300,
...
});
});
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
Class System – Naming Convention
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Classes
Ext.data.Model
Ext.Loader
Ext.data.proxy.Ajax
Source files
Ext.data.Model is stored in /path/to/src/Ext/data/Model.js
Ext.Loader is stored in /path/to/src/Ext/Loader.js
Ext.form.action.Submit is stored in /path/to/src/Ext/form/action/Submi.js
Methods and Variables
encodeUsingMd5()
getHtml()
Properties
Ext.MessageBox.YES
Ext.MessageBox.NO
Class System – Hands On
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Basic Syntax
Ext.define ('MyClass', {prop: val, ...});
Inheritance
Ext.define ('MyClass', {extend: 'OtherClass', …});
Mixins
Ext.define ('MyClass', {mixins: {OtherClass: 'OtherClass'}, …});
Config
Ext.define ('MyClass', {config: {prop: val}, …});
Statics
Ext.define ('MyClass', {statics: {prop: val}, …});
Class System – Basic Syntax
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('KnowsPhp', {
knows: function () {
alert ('I know PHP!');
}
});
Ext.define ('KnowsRuby', {
knows: function () {
alert ('I know Ruby!');
}
});
Ext.define ('KnowsPython', {
knows: function () {
alert ('I know Python!');
}
});
Ext.define ('MyClass', {
constructor: function (cfg) {
// class initialization
return this;
}
});
Ext.define ('My.weird.Class', {
constructor: function (cfg) {
// do something with cfg
return this;
} ,
doSomethingWeird: function () {
// something weird
}
});
Class System – Config
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('Person', {
config: {
name: '' ,
age: 0
} ,
constructor: function (cfg) {
this.initConfig (cfg);
return this;
} ,
applyName: function (name) {
if (name.length === 0)
alert ('Error!');
else {
this.name = name;
return this.name;
}
} ,
applyAge: function (age) {
if ((age < 0) || (age > 99))
alert ('Error!');
else {
this.age = age;
return this.age;
}
}
});
Class System – Inheritance
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('Thief', {
extend: 'Person' ,
steal: function () {
alert (this.getName()+' is
stealing!');
}
});
Ext.define ('Burglar', {
extend: 'Person' ,
lockpick: function () {
alert ('#Lockpicking#');
}
});
Ext.define ('AdvancedThief', {
extend: 'Thief' ,
config: {
tool: ''
} ,
constructor: function (cfg) {
this.initConfig (cfg);
return this;
} ,
steal: function () {
alert ('Stealing with '+this.getTool());
} ,
applyTool: function (tool) {
if (tool.length === 0) alert ('Error!');
else {
this.tool = tool;
return this.tool;
}
}
});
Class System – Mixins
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('Developer', {
extend: 'Person' ,
mixins: {
KnowsPhp: 'KnowsPhp' ,
KnowsRuby: 'KnowsRuby' ,
KnowsPython: 'KnowsPython'
} ,
knowledge: function () {
alert ('Follows what '+this.getName()+' knows:');
this.mixins.KnowsPhp.knows ();
this.mixins.KnowsRuby.knows ();
this.mixins.KnowsPython.knows ();
}
});
Class System – Statics
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('PCCreator', {
statics: {
computerCounter: 0 ,
factory: function (name) {
return new this (name);
}
} ,
config: {
name: ''
} ,
constructor: function (cfg) {
this.initConfig (cfg);
this.self.computerCounter++;
return this;
}
});
var dell = PCCreator.factory ('Dell');
var asus = PCCreator.factory ('Asus');
var hp = PCCreator.factory ('HP');
Alert (dell.name);
Alert (asus.name);
Alert (hp.name);
Alert (PCCreator.computerCounter);
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
Design Patterns
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Singleton (Ext.Class.singleton)
Observer (Ext.util.Observable)
Memento (Ext.util.Memento)
ExtJS is made by different design patterns, like Factory, Bridge, Decorator,
Proxy, etc.
Design Patterns – Singleton
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('My.window.Manager', {
singleton: true ,
config: {
windows: Ext.create ('Ext.util.HashMap')
} ,
register: function (win) {
this.getWindows().add (win.getId (), win);
} ,
unregister: function (id) {
this.getWindows().removeAtKey (id);
}
});
Design Patterns – Singleton
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
var win = Ext.create ('Ext.window.Window', {
id: 'myWin' ,
title: 'My Window' ,
width: 300 ,
height: 300
});
My.window.Manager.register (win);
var myWin = My.window.Manager.getWindows().get (win.getId ());
My.window.Manager.unregister (win.getId ());
Design Patterns – Observer
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.define ('My.observable.Object', {
mixins: {
observable: 'Ext.util.Observable'
} ,
constructor: function (cfg) {
this.initConfig (cfg);
this.mixins.observable.constructor.call (this, cfg);
this.addEvents (['event2fire']);
} ,
doSomething: function () {
this.fireEvent ('event2fire', this, 'Done, dude!');
}
});
Design Patterns – Observer
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
var myObject = Ext.create ('My.observable.Object');
myObject.on ('event2fire', function (myObj, message) {
// Will alert 'Done, dude!'
alert (message);
});
myObject.doSomething ();
Design Patterns – Memento
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
var memento = Ext.create ('Ext.util.Memento');
var obj = {
prop: 10 ,
method: function () {
alert (this.prop);
}
};
obj.method (); // Will alert '10'
memento.capture (['prop', 'method'], obj);
obj.prop = 20;
obj.method = function () {
alert (this.prop + ' numbers');
}
obj.method (); // Will alert '20 numbers'
memento.restoreAll (true, obj);
obj.method (); // Will alert '10'
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
MVC – Architecture
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext JS 4 comes with a new application architecture that not only organizes
your code but reduces the amount you have to write.
Model
Is a collection of fields and their data (e.g. a User model with username and
password fields). Models know how to persist themselves through the data
package, and can be linked to other models through associations. Models are
normally used with Stores to present data into grids and other components.
View
Is any type of component - grids, trees and panels are all views.
Controllers
Are special places to put all of the code that makes your app work - whether that's
rendering views, instantiating Models, or any other app logic.
MVC – Folder Tree
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
File Structure
/var/www/
index.html
app.js
ext/
app/
controller/
model/
store/
view/
MVC – App Definition
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
First of all, the definition of the application, that includes dependencies
requirements, namespace
/project/app.js
// dependencies
Ext.Loader.setConfig ({
enabled: true
});
Ext.require (['*']);
Ext.application ({
// namespace
name: 'MyApp' ,
views: [] ,
models: [] ,
stores: [] ,
controllers: [] ,
// init function
launch: function () {
// initialize the app
}
});
MVC – View
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Views are the representation of data
/project/app/view/MyGrid.js
Ext.define ('MyApp.view.MyGrid', {
extend: 'Ext.grid.Panel' ,
alias: 'widget.mygrid' ,
...
});
/project/app/view/MyMenu.js
Ext.define ('MyApp.view.MyMenu', {
extend: 'Ext.toolbar.Toolbar' ,
alias: 'widget.mymenu' ,
...
});
MVC – View (Viewport)
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Main view, where the other views are rendered
/project/app/view/Viewport.js
Ext.define ('MyApp.view.Viewport', {
extend: 'Ext.container.Viewport' ,
// enable xtypes
requires: [
'MyApp.view.MyGrid' ,
'MyApp.view.MyMenu'
] ,
items: [{
xtype: 'mygrid' ,
title: 'My Grid!' ,
region: 'center' ,
...
} , {
xtype: 'mygrid' ,
title: 'My Menu' ,
region: 'north' ,
...
}]
});
MVC – Model
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Models are the core of data:
they are objects, wrapped in Ext.data.Field class
/project/app/model/MyGrid.js
Ext.define ('MyApp.model.MyGrid', {
extend: 'Ext.data.Model' ,
fields: [
{name: 'age', type: 'int', defaultValue: 1} ,
{name: 'name', type: 'string', defaultValue: 'foo'} ,
{name: 'data', type: 'date' , dateFormat: 'YmdHis'} ,
{name: 'cash', type: 'string' , convert: function (value, record) {
return value + '€';
}}
]
});
And others useful tips for fields: sortDir, useNull, mapping, etc...
Model
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
MVC – Store
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Stores are arrays of model
/project/app/store/MyGrid.js
Ext.define ('MyApp.store.MyGrid', {
extend: 'Ext.data.Store' ,
// name of the model class
model: 'MyApp.model.MyGrid' ,
proxy: {
type: 'ajax' ,
url: '/myUrl' ,
api: {
create: '/myUrl/create' ,
read: '/myUrl/read' ,
update: '/myUrl/update' ,
destroy: '/myUrl/destroy'
} ,
reader: {
type: 'json' ,
root: 'User' ,
record: 'users'
}
}
});
Data Package
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
MVC – Controller
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Controllers are the glue between models/stores and views:
all the app logic is handled here
/project/app/controller/MyGrid.js
Ext.define ('MyApp.controller.MyGrid', {
extend: 'Ext.app.Controller' ,
views: ['MyGrid'] ,
models: ['MyGrid'] ,
stores: ['MyGrid'] ,
init: function () {
this.control ({
'mygrid': {
itemdblclick: this.workOnRow
}
});
} ,
workOnRow: function (grid, record) {
this.getMyGridStore().load();
...
}
});
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
Charts
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Charts – Definition
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.create ('Ext.chart.Chart', {
width: 300 ,
height: 300 ,
store: store,
axes: [{
title: 'Name' ,
fields: ['name'] ,
position: 'bottom',
type: 'Category'
} , {
title: 'Balances',
position: 'left',
fields: ['balance'] ,
type: 'Numeric'
}] ,
series: [{
type: 'line',
xField: 'name',
yField: 'balance'
}]
});
One of the innovation that comes with ExtJS is Ext.chart.Chart
Charts – Axes
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Axes types
Axis: base class
Category: A type of axis that displays items in
categories.
Gauge: Gauge Axis is the axis to be used with a
Gauge series. The Gauge axis displays numeric
data from an interval.
Numeric: An axis to handle numeric values.
Time: A type of axis whose units are measured
in time values.
axes: [{
title: 'Name' ,
fields: ['name'] ,
position: 'bottom',
type: 'Category'
} , {
title: 'Balances',
position: 'left',
fields: ['balance'] ,
type: 'Numeric'
}]
Axes are the lines that define the boundaries of the data points that a Chart
can display.
Charts – Series
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
series: [{
type: 'line',
xField: 'name',
yField: 'balance'
}]
Series are responsible for the visual representation of the data points
contained in the Store.
Series
Area
Bar
Cartesian
Column
Series types
Gauge
Line
Pie
Radar
Scatter
Index
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
1. Loader
2. Class System
3. Design Patterns
4. MVC
5. Charts
6. Misc (dafaq?)
Utilities
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Native Extensions
Ext.Array
Ext.Object
Ext.String
Ext.JSON
Ext.Function
Utility
Ext.util.Sorter
Ext.util.Sortable
Ext.util.HashMap
Ext.util.Filter
Events
Ext.TaskManager
Ext.EventManager
Ext.EventObject
Ext.util.Observable
Ext
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
The Ext namespace (global object) encapsulates all classes, singletons, and
utility methods provided by Sencha's libraries.
Properties
isChrome
isSafari
isIE
isOpera
isGecko
isWebKit
isLinux
isMac
isWindows
Methods
create
each
get
getCmp
getDom
getStore
isArray
isEmpty
isObject
onDocumentReady
onReady
Ext - Examples
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Ext.create
var win = Ext.create ('Ext.window.Window', {id: 'win1'});
Ext.each
var operatingSystems = ['Linux', 'Mac', 'Windows'];
Ext.each (operatingSystems, function (item, index, array) {
alert ('Current OS is: ' + item);
});
Ext.get
<div id=”chatlog”>......</div>
var cl = Ext.get ('chatlog');
cl.setVisible (false);
Ext.getCmp
var win = Ext.getCmp ('win1');
Credits
License : Creative Commons (Attribution , Share Alike) 3.0 Generic
Vincenzo Ferrari
wilk3ert@gmail.com

Weitere ähnliche Inhalte

Was ist angesagt?

Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrideugenio pombi
 
Python Asíncrono - Async Python
Python Asíncrono - Async PythonPython Asíncrono - Async Python
Python Asíncrono - Async PythonJavier Abadía
 
CUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" courseCUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" courseShuai Yuan
 
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...Unity Technologies Japan K.K.
 
Rails' Next Top Model
Rails' Next Top ModelRails' Next Top Model
Rails' Next Top ModelAdam Keys
 

Was ist angesagt? (8)

Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
From newbie to ...
From newbie to ...From newbie to ...
From newbie to ...
 
Python Asíncrono - Async Python
Python Asíncrono - Async PythonPython Asíncrono - Async Python
Python Asíncrono - Async Python
 
CUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" courseCUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" course
 
isd312-05-wordnet
isd312-05-wordnetisd312-05-wordnet
isd312-05-wordnet
 
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...
【Unite Tokyo 2018】“100 Must-see Assets for 2018” by Virtual YouTuber, Cyber G...
 
Air superiority for Android Apps
Air superiority for Android AppsAir superiority for Android Apps
Air superiority for Android Apps
 
Rails' Next Top Model
Rails' Next Top ModelRails' Next Top Model
Rails' Next Top Model
 

Ähnlich wie ExtJS framework

Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
SenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioSenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioNils Dehl
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridGiorgio Cefaro
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSAprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSLoiane Groner
 
There's more than web
There's more than webThere's more than web
There's more than webMatt Evans
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and BeyondMarakana Inc.
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)Google
 
SenchaCon 2010: Developing components and extensions for ext js
SenchaCon 2010: Developing components and extensions for ext jsSenchaCon 2010: Developing components and extensions for ext js
SenchaCon 2010: Developing components and extensions for ext jsMats Bryntse
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWAREFIWARE
 
Browser Extensions for Web Hackers
Browser Extensions for Web HackersBrowser Extensions for Web Hackers
Browser Extensions for Web HackersMark Wubben
 
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docx
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docxCross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docx
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docxmydrynan
 
Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Ciaran McHale
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSPVS-Studio
 

Ähnlich wie ExtJS framework (20)

Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
SenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioSenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.io
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
XSS
XSSXSS
XSS
 
XSS
XSSXSS
XSS
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSAprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
 
There's more than web
There's more than webThere's more than web
There's more than web
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and Beyond
 
Book
BookBook
Book
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
SenchaCon 2010: Developing components and extensions for ext js
SenchaCon 2010: Developing components and extensions for ext jsSenchaCon 2010: Developing components and extensions for ext js
SenchaCon 2010: Developing components and extensions for ext js
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
Browser Extensions for Web Hackers
Browser Extensions for Web HackersBrowser Extensions for Web Hackers
Browser Extensions for Web Hackers
 
Android - Api & Debugging in Android
Android - Api & Debugging in AndroidAndroid - Api & Debugging in Android
Android - Api & Debugging in Android
 
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docx
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docxCross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docx
Cross-site scripting (XSS) AttacksCross-site scripting (XSS) i.docx
 
Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Generic Synchronization Policies in C++
Generic Synchronization Policies in C++
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
 

Mehr von Vincenzo Ferrari

Mehr von Vincenzo Ferrari (6)

Microjob
MicrojobMicrojob
Microjob
 
Tick
TickTick
Tick
 
AngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroesAngularJS - Javascript framework for superheroes
AngularJS - Javascript framework for superheroes
 
Time management
Time managementTime management
Time management
 
Angularjs
AngularjsAngularjs
Angularjs
 
ExtJS: a powerful Javascript framework
ExtJS: a powerful Javascript frameworkExtJS: a powerful Javascript framework
ExtJS: a powerful Javascript framework
 

Kürzlich hochgeladen

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Kürzlich hochgeladen (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

ExtJS framework

  • 1. License : Creative Commons (Attribution , Share Alike) 3.0 Generic A powerful javascript framework by Vincenzo Ferrari
  • 2. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 3. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 4. Ext.Loader License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most commonly used via the Ext.require shorthand. Ext.Loader supports both asynchronous and synchronous loading approaches. Asynchronous Loading Advantages Cross-domain No web server needed Best possible debugging Disadvantages Dependencies need to be specified before-hand Synchronous Loading on Demand Advantages There's no need to specify dependencies before-hand Disadvantages Not as good debugging experience Must be from the same domain due to XHR restriction Need a web server Hybrid Solution It has all the advantages combined from asynchronous and synchronous loading
  • 5. Ext.Loader – Sync License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.create & Ext.widget // Instead of new Ext.window.Window({...}); Ext.create('widget.window', { ... }); // Same as above, using full class name instead of alias Ext.create('Ext.window.Window', {}); // Same as above, all you need is the traditional `xtype` Ext.widget('window', {}); Behind the scene, Ext.ClassManager will automatically check whether the given class name / alias has already existed on the page. If it's not, Ext.Loader will immediately switch itself to synchronous mode and automatic load the given class and all its dependencies.
  • 6. Ext.Loader – Async License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.require // Syntax Ext.require({String/Array} expressions); // Single alias Ext.require('widget.window'); // Single class name Ext.require('Ext.window.Window'); // Multiple aliases / class names mix Ext.require(['widget.window', 'layout.border', 'Ext.data.Connection']); // Wildcards Ext.require(['widget.*', 'layout.*', 'Ext.data.*']); Ext.exclude // Syntax: Note that it must be in this chaining format. Ext.exclude({String/Array} expressions) .require({String/Array} expressions); // Include everything except Ext.data.* Ext.exclude('Ext.data.*').require('*'); // Include all widgets except widget.checkbox*,which will match widget.checkbox, widget.checkboxfield, widget.checkboxgroup, etc. Ext.exclude('widget.checkbox*').require('wi dget.*');
  • 7. Ext.Loader – Hybrid License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.create + Ext.require // Enable the dynamic dependency loading feature Ext.Loader.setConfig ({ enabled: true }); Ext.require (['Ext.window.Window']); // Ready when all dependecies has loaded Ext.onReady(function () { var window = Ext.create ('Ext.window.Window', { title: 'My Window', width: 300, height: 300, ... }); });
  • 8. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 9. Class System – Naming Convention License : Creative Commons (Attribution , Share Alike) 3.0 Generic Classes Ext.data.Model Ext.Loader Ext.data.proxy.Ajax Source files Ext.data.Model is stored in /path/to/src/Ext/data/Model.js Ext.Loader is stored in /path/to/src/Ext/Loader.js Ext.form.action.Submit is stored in /path/to/src/Ext/form/action/Submi.js Methods and Variables encodeUsingMd5() getHtml() Properties Ext.MessageBox.YES Ext.MessageBox.NO
  • 10. Class System – Hands On License : Creative Commons (Attribution , Share Alike) 3.0 Generic Basic Syntax Ext.define ('MyClass', {prop: val, ...}); Inheritance Ext.define ('MyClass', {extend: 'OtherClass', …}); Mixins Ext.define ('MyClass', {mixins: {OtherClass: 'OtherClass'}, …}); Config Ext.define ('MyClass', {config: {prop: val}, …}); Statics Ext.define ('MyClass', {statics: {prop: val}, …});
  • 11. Class System – Basic Syntax License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('KnowsPhp', { knows: function () { alert ('I know PHP!'); } }); Ext.define ('KnowsRuby', { knows: function () { alert ('I know Ruby!'); } }); Ext.define ('KnowsPython', { knows: function () { alert ('I know Python!'); } }); Ext.define ('MyClass', { constructor: function (cfg) { // class initialization return this; } }); Ext.define ('My.weird.Class', { constructor: function (cfg) { // do something with cfg return this; } , doSomethingWeird: function () { // something weird } });
  • 12. Class System – Config License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('Person', { config: { name: '' , age: 0 } , constructor: function (cfg) { this.initConfig (cfg); return this; } , applyName: function (name) { if (name.length === 0) alert ('Error!'); else { this.name = name; return this.name; } } , applyAge: function (age) { if ((age < 0) || (age > 99)) alert ('Error!'); else { this.age = age; return this.age; } } });
  • 13. Class System – Inheritance License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('Thief', { extend: 'Person' , steal: function () { alert (this.getName()+' is stealing!'); } }); Ext.define ('Burglar', { extend: 'Person' , lockpick: function () { alert ('#Lockpicking#'); } }); Ext.define ('AdvancedThief', { extend: 'Thief' , config: { tool: '' } , constructor: function (cfg) { this.initConfig (cfg); return this; } , steal: function () { alert ('Stealing with '+this.getTool()); } , applyTool: function (tool) { if (tool.length === 0) alert ('Error!'); else { this.tool = tool; return this.tool; } } });
  • 14. Class System – Mixins License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('Developer', { extend: 'Person' , mixins: { KnowsPhp: 'KnowsPhp' , KnowsRuby: 'KnowsRuby' , KnowsPython: 'KnowsPython' } , knowledge: function () { alert ('Follows what '+this.getName()+' knows:'); this.mixins.KnowsPhp.knows (); this.mixins.KnowsRuby.knows (); this.mixins.KnowsPython.knows (); } });
  • 15. Class System – Statics License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('PCCreator', { statics: { computerCounter: 0 , factory: function (name) { return new this (name); } } , config: { name: '' } , constructor: function (cfg) { this.initConfig (cfg); this.self.computerCounter++; return this; } }); var dell = PCCreator.factory ('Dell'); var asus = PCCreator.factory ('Asus'); var hp = PCCreator.factory ('HP'); Alert (dell.name); Alert (asus.name); Alert (hp.name); Alert (PCCreator.computerCounter);
  • 16. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 17. Design Patterns License : Creative Commons (Attribution , Share Alike) 3.0 Generic Singleton (Ext.Class.singleton) Observer (Ext.util.Observable) Memento (Ext.util.Memento) ExtJS is made by different design patterns, like Factory, Bridge, Decorator, Proxy, etc.
  • 18. Design Patterns – Singleton License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('My.window.Manager', { singleton: true , config: { windows: Ext.create ('Ext.util.HashMap') } , register: function (win) { this.getWindows().add (win.getId (), win); } , unregister: function (id) { this.getWindows().removeAtKey (id); } });
  • 19. Design Patterns – Singleton License : Creative Commons (Attribution , Share Alike) 3.0 Generic var win = Ext.create ('Ext.window.Window', { id: 'myWin' , title: 'My Window' , width: 300 , height: 300 }); My.window.Manager.register (win); var myWin = My.window.Manager.getWindows().get (win.getId ()); My.window.Manager.unregister (win.getId ());
  • 20. Design Patterns – Observer License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.define ('My.observable.Object', { mixins: { observable: 'Ext.util.Observable' } , constructor: function (cfg) { this.initConfig (cfg); this.mixins.observable.constructor.call (this, cfg); this.addEvents (['event2fire']); } , doSomething: function () { this.fireEvent ('event2fire', this, 'Done, dude!'); } });
  • 21. Design Patterns – Observer License : Creative Commons (Attribution , Share Alike) 3.0 Generic var myObject = Ext.create ('My.observable.Object'); myObject.on ('event2fire', function (myObj, message) { // Will alert 'Done, dude!' alert (message); }); myObject.doSomething ();
  • 22. Design Patterns – Memento License : Creative Commons (Attribution , Share Alike) 3.0 Generic var memento = Ext.create ('Ext.util.Memento'); var obj = { prop: 10 , method: function () { alert (this.prop); } }; obj.method (); // Will alert '10' memento.capture (['prop', 'method'], obj); obj.prop = 20; obj.method = function () { alert (this.prop + ' numbers'); } obj.method (); // Will alert '20 numbers' memento.restoreAll (true, obj); obj.method (); // Will alert '10'
  • 23. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 24. MVC – Architecture License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext JS 4 comes with a new application architecture that not only organizes your code but reduces the amount you have to write. Model Is a collection of fields and their data (e.g. a User model with username and password fields). Models know how to persist themselves through the data package, and can be linked to other models through associations. Models are normally used with Stores to present data into grids and other components. View Is any type of component - grids, trees and panels are all views. Controllers Are special places to put all of the code that makes your app work - whether that's rendering views, instantiating Models, or any other app logic.
  • 25. MVC – Folder Tree License : Creative Commons (Attribution , Share Alike) 3.0 Generic File Structure /var/www/ index.html app.js ext/ app/ controller/ model/ store/ view/
  • 26. MVC – App Definition License : Creative Commons (Attribution , Share Alike) 3.0 Generic First of all, the definition of the application, that includes dependencies requirements, namespace /project/app.js // dependencies Ext.Loader.setConfig ({ enabled: true }); Ext.require (['*']); Ext.application ({ // namespace name: 'MyApp' , views: [] , models: [] , stores: [] , controllers: [] , // init function launch: function () { // initialize the app } });
  • 27. MVC – View License : Creative Commons (Attribution , Share Alike) 3.0 Generic Views are the representation of data /project/app/view/MyGrid.js Ext.define ('MyApp.view.MyGrid', { extend: 'Ext.grid.Panel' , alias: 'widget.mygrid' , ... }); /project/app/view/MyMenu.js Ext.define ('MyApp.view.MyMenu', { extend: 'Ext.toolbar.Toolbar' , alias: 'widget.mymenu' , ... });
  • 28. MVC – View (Viewport) License : Creative Commons (Attribution , Share Alike) 3.0 Generic Main view, where the other views are rendered /project/app/view/Viewport.js Ext.define ('MyApp.view.Viewport', { extend: 'Ext.container.Viewport' , // enable xtypes requires: [ 'MyApp.view.MyGrid' , 'MyApp.view.MyMenu' ] , items: [{ xtype: 'mygrid' , title: 'My Grid!' , region: 'center' , ... } , { xtype: 'mygrid' , title: 'My Menu' , region: 'north' , ... }] });
  • 29. MVC – Model License : Creative Commons (Attribution , Share Alike) 3.0 Generic Models are the core of data: they are objects, wrapped in Ext.data.Field class /project/app/model/MyGrid.js Ext.define ('MyApp.model.MyGrid', { extend: 'Ext.data.Model' , fields: [ {name: 'age', type: 'int', defaultValue: 1} , {name: 'name', type: 'string', defaultValue: 'foo'} , {name: 'data', type: 'date' , dateFormat: 'YmdHis'} , {name: 'cash', type: 'string' , convert: function (value, record) { return value + '€'; }} ] }); And others useful tips for fields: sortDir, useNull, mapping, etc...
  • 30. Model License : Creative Commons (Attribution , Share Alike) 3.0 Generic
  • 31. MVC – Store License : Creative Commons (Attribution , Share Alike) 3.0 Generic Stores are arrays of model /project/app/store/MyGrid.js Ext.define ('MyApp.store.MyGrid', { extend: 'Ext.data.Store' , // name of the model class model: 'MyApp.model.MyGrid' , proxy: { type: 'ajax' , url: '/myUrl' , api: { create: '/myUrl/create' , read: '/myUrl/read' , update: '/myUrl/update' , destroy: '/myUrl/destroy' } , reader: { type: 'json' , root: 'User' , record: 'users' } } });
  • 32. Data Package License : Creative Commons (Attribution , Share Alike) 3.0 Generic
  • 33. MVC – Controller License : Creative Commons (Attribution , Share Alike) 3.0 Generic Controllers are the glue between models/stores and views: all the app logic is handled here /project/app/controller/MyGrid.js Ext.define ('MyApp.controller.MyGrid', { extend: 'Ext.app.Controller' , views: ['MyGrid'] , models: ['MyGrid'] , stores: ['MyGrid'] , init: function () { this.control ({ 'mygrid': { itemdblclick: this.workOnRow } }); } , workOnRow: function (grid, record) { this.getMyGridStore().load(); ... } });
  • 34. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts
  • 35. Charts License : Creative Commons (Attribution , Share Alike) 3.0 Generic
  • 36. Charts – Definition License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.create ('Ext.chart.Chart', { width: 300 , height: 300 , store: store, axes: [{ title: 'Name' , fields: ['name'] , position: 'bottom', type: 'Category' } , { title: 'Balances', position: 'left', fields: ['balance'] , type: 'Numeric' }] , series: [{ type: 'line', xField: 'name', yField: 'balance' }] }); One of the innovation that comes with ExtJS is Ext.chart.Chart
  • 37. Charts – Axes License : Creative Commons (Attribution , Share Alike) 3.0 Generic Axes types Axis: base class Category: A type of axis that displays items in categories. Gauge: Gauge Axis is the axis to be used with a Gauge series. The Gauge axis displays numeric data from an interval. Numeric: An axis to handle numeric values. Time: A type of axis whose units are measured in time values. axes: [{ title: 'Name' , fields: ['name'] , position: 'bottom', type: 'Category' } , { title: 'Balances', position: 'left', fields: ['balance'] , type: 'Numeric' }] Axes are the lines that define the boundaries of the data points that a Chart can display.
  • 38. Charts – Series License : Creative Commons (Attribution , Share Alike) 3.0 Generic series: [{ type: 'line', xField: 'name', yField: 'balance' }] Series are responsible for the visual representation of the data points contained in the Store. Series Area Bar Cartesian Column Series types Gauge Line Pie Radar Scatter
  • 39. Index License : Creative Commons (Attribution , Share Alike) 3.0 Generic 1. Loader 2. Class System 3. Design Patterns 4. MVC 5. Charts 6. Misc (dafaq?)
  • 40. Utilities License : Creative Commons (Attribution , Share Alike) 3.0 Generic Native Extensions Ext.Array Ext.Object Ext.String Ext.JSON Ext.Function Utility Ext.util.Sorter Ext.util.Sortable Ext.util.HashMap Ext.util.Filter Events Ext.TaskManager Ext.EventManager Ext.EventObject Ext.util.Observable
  • 41. Ext License : Creative Commons (Attribution , Share Alike) 3.0 Generic The Ext namespace (global object) encapsulates all classes, singletons, and utility methods provided by Sencha's libraries. Properties isChrome isSafari isIE isOpera isGecko isWebKit isLinux isMac isWindows Methods create each get getCmp getDom getStore isArray isEmpty isObject onDocumentReady onReady
  • 42. Ext - Examples License : Creative Commons (Attribution , Share Alike) 3.0 Generic Ext.create var win = Ext.create ('Ext.window.Window', {id: 'win1'}); Ext.each var operatingSystems = ['Linux', 'Mac', 'Windows']; Ext.each (operatingSystems, function (item, index, array) { alert ('Current OS is: ' + item); }); Ext.get <div id=”chatlog”>......</div> var cl = Ext.get ('chatlog'); cl.setVisible (false); Ext.getCmp var win = Ext.getCmp ('win1');
  • 43. Credits License : Creative Commons (Attribution , Share Alike) 3.0 Generic Vincenzo Ferrari wilk3ert@gmail.com