SlideShare a Scribd company logo
Developing Components and Extensions for Ext JS2011 Mats Bryntse
About mepresenter = {name:”Mats Bryntse”,     	from:”Helsingborg, Sweden”,usingExtSince:2007,website : ”www.bryntum.com”,,    	twitter: ”@bryntum”};
Before we start...Let’s do a raise of hands
How many has heard of:jQuery?
Ext JS?If you haven’t seen/heardwww.sencha.com
How I met Ext JSStumbled upon Ext 2007 at SEMC
Mission: Internal portal application
Data-heavy application
Lots of data input, forms etc.
Lots of tables to display
Had to run on the best, most awesome browser in the worldCan you guess which one?
RequirementsSolid grid – Lots of data lists
Architechture – data stores, widgets
Polished UI without requiring deep HTMLor CSS knowledge.We prototypedMicrosoft AjaxjQueryExt JS
Scoreboard
ResultExt JS worked out well!
Customer happy
But... one feature we couldn’t solve using pure Ext JS at that time
A visual scheduling widgetCustomer wants:
Search beganFound a few flash ones, not allowed to use
No JavaScript based ones, hardly any web based either
But after serious Googling research we did find something...”WidgetX”Image blurred to protect you
Widget X reviewIs it JavaScript based?
So, is it interactive?
Is it at least beautiful?
Implement it anyway?ASP.NETNo, sirNoHell Yeah!
Customer wantedCustomer got#FAIL
Fast forward to 2009>>
I decided to write my own
ConclusionWriting Ext JS components is a lot of fun (and addictive)
So where do I start?WTF??
Visit www.sencha.comGetExt JS SDKsencha.com/learn
Ext JS Terminology & ConceptsExt Component
Ext Container
Extension
Plugin
MixinExt.ComponentBase class for most popular Ext widgets (GridPanel, TabPanel, TextField etc...)Can be part of any layout structure as a child of a Container.
All subclasses of Component has a managed lifecycle (creation, rendering and destruction)which is provided by the Container class. Ext.Component: Base class for most popular Ext widgets
Ext.ComponentCan be part of any layout structure as a child of a Container.Ext.Component lifecycleAll subclasses of Component has a managed lifecycle (creation, rendering and destruction)which is provided by the Container class. ConstructorInitializeRenderDestroy
Ext.Component lifecycle and template methods* Initialization (constructor, initComponent)       - Configuration, setup etc...* Rendering (onRender, afterRender)	- Add additional elements and markup* Layout (afterLayout)	- Executed after the component has been laid out* Destruction (onDestroy)        - Clean up after yourself, destroy elements etc.
Ext.ContainerBase class for any Component that needs to contain other Components.
Handles the basic behavior of containing items: adding, inserting and removingitems.
The most commonly used Container classes are Panel, Window and TabPanel.What is an Ext JS extension??
Ext JS extensionSubclassing an Ext JS ”class”
Doesn’t have to be UI-related
Reusable throughout your appSimple extensionExt.define('MyClass', {	extend: ’Ext.TabPanel’,constructor: function() {		alert(”Look ma, I have tabs”);this.callParent();	}}); 
Class propertiesThe properties and methods you define for your class are added to the prototype of your class.Ext.define('MyClass', {	extend: ’Ext.TabPanel’,    favoriteTab : 3,   someFunction : function() { ... }});console.log(MyClass.prototype.favoriteTab); // => 3
Instantiating your classvar foo = Ext.create('MyClass', {// Config properties}); // Or just use classic ’new’var bar = new MyClass({// Config properties});
Mixins
MixinsBrand new concept when it comes to Ext JS 4. A mixin is just a set of functions (and sometimes properties) that are merged into a class.
Mixins are really useful when a class needs to inherit multiple traits but can’t do so easily using a traditional single inheritance mechanismMixins - exampleExt.Windowis a draggable component, as are Sliders, Grid headers, and many others Mixins - exampleBecause this behavior is desired in many different places it’s not feasible to work the draggable behavior into a single superclass
Creating a Draggablemixin solves this problem – anything can now be draggable very easily.Mixins// We can define some mixins at definition timeExt.define('MyClass', {	mixins: {		observable: 'Ext.util.Observable'	}}); // It’s easy to add more later tooMyClass.mixin('draggable', 'Ext.util.Draggable');
Plugins
PluginsA plugin augments a single instance of an Ext Component. Any object with an initmethod.
Used to add a feature to a component, for example adding cell-editing to a GridPanel.
During its initialization phase, the host component calls the init method of all its plugins, and passes itself as the only argumentDefining a plugin// Simplest possible pluginvar mySillyPlug = {    init : function(host) { alert(’Hello world’); }}; 
Using a plugin// Adding inline editing support to grid cellsExt.create(’Ext.grid.Panel',{	plugins: Ext.create('Ext.grid.plugin.CellEditing', {   		clicksToEdit: 1 })}); 
Let’s create a simple extension!
A simple CSS 3 clock component
Step 1. Identify suitable base class
Step 2. Create a simple HTML page and JS files
Step 3. Create extension skeleton classExt.define(”AwesomeClock”, {extend : ”Ext.Component”,cls: “myclock”,  // A CSS class for styling	afterRender : function() {// Call superclassthis.callParent(arguments);}});
Step 3.5: simple app.jsapplication filenewAwesomeClock({    width : 320,    height : 320,    renderTo : Ext.getBody()});
Step 3.99: HTML file<html><head><!-- Ext JS CSS --><linkrel="stylesheet"type="text/css"href="ext-4.0.0/ext-all.css"/><!-- Our CSS for the extension --><linkhref="css/awesomeclock.css"rel="stylesheet"type="text/css"/><!-- Ext JS Library --><scriptsrc="ext-4.0.0/bootstrap.js"type="text/javascript"></script><!--Our own classes--><scripttype="text/javascript"src="js/awesomeclock.js"></script><!--Simple Test App File--><scripttype="text/javascript"src="app.js"></script></head><body></body></html>
Step 4. Does it run?
Step 5. Let’s add some codeafterRender : function() {this.callParent(arguments);this.hourHand = this.el.createChild({...});this.minuteHand = this.el.createChild({...});this.date = new Date();setInterval(Ext.Function.bind(this.updateHands, this), 1000);Ext.Function.defer(this.updateHands, 100, this);},updateHands : function() { ... }
Step 6. Does it still run?
Step 7. Let’s add some CSS(3).myclock{background:-moz-linear-gradient(bottom, blue, navy);border-radius: 100%;position:relative;border:2pxsolidwhite;-moz-transition: all0.4sease-in-out;}.myclock-hand{width : 10px;position:absolute;left:49%;-moz-transition: all1sease-in-out;border-radius: 10px10px00;}

More Related Content

PDF
Creating Ext JS Extensions and Components
PDF
Four Ways to add Features to Ext JS
PDF
Ext JS 4.0 - Creating extensions, plugins and components
PPTX
Javascript Common Design Patterns
PPT
ExtJs Basic Part-1
PDF
Twig tips and tricks
PPTX
Sencha / ExtJS : Object Oriented JavaScript
PDF
The Naked Bundle - Tryout
Creating Ext JS Extensions and Components
Four Ways to add Features to Ext JS
Ext JS 4.0 - Creating extensions, plugins and components
Javascript Common Design Patterns
ExtJs Basic Part-1
Twig tips and tricks
Sencha / ExtJS : Object Oriented JavaScript
The Naked Bundle - Tryout

What's hot (20)

PDF
Doctrine with Symfony - SymfonyCon 2019
PDF
Scalable JavaScript Design Patterns
PDF
Twig Brief, Tips&Tricks
PDF
Symfony & Javascript. Combining the best of two worlds
PDF
Workshop 10: ECMAScript 6
PPTX
Workshop 1: Good practices in JavaScript
PDF
The Naked Bundle - Symfony Barcelona
PDF
JavaScript and UI Architecture Best Practices
KEY
jQuery Namespace Pattern
PDF
Workshop 5: JavaScript testing
PDF
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
KEY
A tour on ruby and friends
PDF
Using Objects to Organize your jQuery Code
PDF
A New Baseline for Front-End Devs
PDF
Javascript Design Patterns
PDF
Dependency Injection with PHP 5.3
PDF
Symfony2 revealed
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
PDF
Class-based views with Django
Doctrine with Symfony - SymfonyCon 2019
Scalable JavaScript Design Patterns
Twig Brief, Tips&Tricks
Symfony & Javascript. Combining the best of two worlds
Workshop 10: ECMAScript 6
Workshop 1: Good practices in JavaScript
The Naked Bundle - Symfony Barcelona
JavaScript and UI Architecture Best Practices
jQuery Namespace Pattern
Workshop 5: JavaScript testing
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
A tour on ruby and friends
Using Objects to Organize your jQuery Code
A New Baseline for Front-End Devs
Javascript Design Patterns
Dependency Injection with PHP 5.3
Symfony2 revealed
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Class-based views with Django
Ad

Similar to Developing components and extensions for ext js (20)

PPTX
Building Rich Internet Applications with Ext JS
PPTX
SenchaCon 2010: Developing components and extensions for ext js
PPTX
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
PPTX
Ext JS Introduction
PDF
Ext JS in Action 1st Edition Jesus Garcia
PPTX
Ext JS Presentation
PPTX
Extension Javascript
PPT
ExtjsPart1
PPTX
Ext Js introduction and new features in Ext Js 6
PPTX
Introduction to ExtJS and its new features
PPTX
Ext JS Architecture Best Practices - Mitchell Simeons
PPT
Ext Js
ODP
ExtJS framework
PDF
Architecting your app in ext js 4, part 1 learn sencha
PDF
Cross Platform Mobile App Development - An Introduction to Sencha Touch
PPTX
Three Pillar Global Design For Use
PPTX
Kickstart sencha extjs
PPTX
Sencha Touch - Introduction
PPTX
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
PPT
Introduction to the ExtJS Javascript framework for rich apps in every browser
Building Rich Internet Applications with Ext JS
SenchaCon 2010: Developing components and extensions for ext js
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
Ext JS Introduction
Ext JS in Action 1st Edition Jesus Garcia
Ext JS Presentation
Extension Javascript
ExtjsPart1
Ext Js introduction and new features in Ext Js 6
Introduction to ExtJS and its new features
Ext JS Architecture Best Practices - Mitchell Simeons
Ext Js
ExtJS framework
Architecting your app in ext js 4, part 1 learn sencha
Cross Platform Mobile App Development - An Introduction to Sencha Touch
Three Pillar Global Design For Use
Kickstart sencha extjs
Sencha Touch - Introduction
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
Introduction to the ExtJS Javascript framework for rich apps in every browser
Ad

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
Review of recent advances in non-invasive hemoglobin estimation
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Developing components and extensions for ext js