+ All Categories
Home > Technology > Ext JS Introduction

Ext JS Introduction

Date post: 16-Nov-2014
Category:
Upload: anand-dayalan
View: 2,419 times
Download: 1 times
Share this document with a friend
Description:
 
Popular Tags:
25
- Anand Dayalan
Transcript
Page 1: Ext JS Introduction

- Anand Dayalan

Page 2: Ext JS Introduction

• A JavaScript Framework for RIA • Developed and Supported Sencha Inc• Started as extension to Yahoo's YUI

What is Ext JS?

Page 3: Ext JS Introduction

Features and Highlights

• Rich, Modern UI Widgets• Layout Controls• MVC Application Architecture• Charts• Data Package• Cross Browser Support

Page 4: Ext JS Introduction

Ext JS vs jQuery

Ext JS• Not free for commercial• Competitively Smaller

Community• Inbuilt powerful UI widgets• RIA - Super Easy• MVC Application

Architecture• Excellent Charts• Excellent Layout Controls

jQuery• Free• Most famous, Huge

Community• Lacks complex UI elements• RIA - Not Easy• No MVC

• No Charts• No Layout Controls

Page 5: Ext JS Introduction

Ext JS vs jQuery

Ext JS• Rich data management• Little bit Longer Learning

Curve• Complete and Robust• Library Size More• Easy Development and

Maintenance• Good Code Readability• Better Documentation and

Samples

jQuery• No• Easy to Start

• Not that much• Lightweight• Complex

• No• Not Bad

Page 6: Ext JS Introduction

Which one to use?

Ext JS• Complex UI• Lots of Windows and

Section• Desktop Like• Admin Web App• Don’t want to use any

server side scripting language or HTML

jQuery• Need to work with HTML

you define• Already have running

application and only need some DOM manipulation

• Need to some AJAX/JS tweaking to an existing UI

Page 7: Ext JS Introduction

Can I use both?

Yes

Page 8: Ext JS Introduction

Hello world<html> <body><link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css" /><script type="text/javascript" src="../../ext-all.js"></script><script language="javascript" src="helloworld.js"></script></body> </html>Ext.application({ launch: function() { Ext.create('Ext.container.Viewport', { layout: 'fit', items: [ { title: 'Hello Ext', html : 'Hello! Welcome to Ext JS.' } ] }); }});

Page 9: Ext JS Introduction

Some Basics - Components

var button = new Ext.Button({ text: ‘Click me!‘, width: 100, height: 20});

var panel= new Ext.Panel({ title: 'A Panel', border: true, items: [ new Ext.Panel({ { xtype: ‘panel’, title: ‘Child panel!‘ title: ‘Child Panel’ }) } ]});

Page 10: Ext JS Introduction

Some Basics - Eventsvar button = new Ext.Button({ text: 'Click me!', width: 100, height: 20, listeners: { 'click': function() { alert('Clicked!'); } }});

btn.on('mouseover', function() { alert(‘Mouse Over');});

Page 11: Ext JS Introduction

DOM Pointers

Each dom node has 5 pointers which allow you to navigate through the DOM

parentNodepreviousSiblingnextSiblingfirstChildlastChild

Page 12: Ext JS Introduction

Ext.DomQueryExt.get('myEl')Ext.select('div.foo, span.bar');Ext.get('myEl').select('div.foo'); or Ext.select('div.foo', true, 'myEl');Ext.select('div.foo[title=bar]:first');Ext.select('div span');Ext.select('div > span');Ext.select('a[href=http://extjs.com]'); Ext.select('div:next(span.header)); Ext.select('div:{display=none}'); http://docs.sencha.com/core/manual/content/domquery.html

Page 13: Ext JS Introduction

Inheritance

MyClass = Ext.extend(Ext.SomeClass, { someFunction : function(arg1, arg2){ // custom code // call base class MyClass.superclass.someFunction.call(this,

arg1, arg2); // custom code });

Page 14: Ext JS Introduction

Layouts• Absolute• Accordion• Anchor• Border• Card (TabPanel)• Card (Wizard)• Column• Fit• Table• vbox• hBox

– http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/layout-browser/layout-browser.html

Page 15: Ext JS Introduction

MVC

• Model is a collection of fields and their data. Models know how to persist themselves through the data package.

• 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.– http://docs.sencha.com/ext-js/4-1/#!/guide/application_

architecture– http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/ap

p/feed-viewer/feed-viewer.html

Page 16: Ext JS Introduction

Application and ViewportExt.application({ requires: ['Ext.container.Viewport'], name: 'AM‘, appFolder: 'app‘, controllers: [ 'Users' ], launch: function() { Ext.create('Ext.container.Viewport', { layout: 'fit', items: [ { xtype: 'userlist‘ } ] }); }});

Page 17: Ext JS Introduction

ControllerExt.define('AM.controller.Users', { extend: 'Ext.app.Controller', views: [ 'user.List’ ], stores: ['Users’ ], models: ['User'], init: function() { this.control({ 'userlist': { itemdblclick: this.editUser } }); }, editUser: function(grid, record) { console.log('Double clicked on ' + record.get('name')); }});

Page 18: Ext JS Introduction

ViewExt.define('AM.view.user.List' ,{ extend: 'Ext.grid.Panel', alias: 'widget.userlist‘, title: 'All Users', store: 'Users', initComponent: function() { this.columns = [ {header: 'Name', dataIndex: 'name', flex: 1}, {header: 'Email', dataIndex: 'email', flex: 1} ]; this.callParent(arguments); }});

Page 19: Ext JS Introduction

Model

Ext.define('AM.model.User', { extend: 'Ext.data.Model', fields: ['name', 'email']});

Page 20: Ext JS Introduction

Communication Between Controllers

1. Add MyApp.app = this; in application 2. Declare a variable for controller in application3. Set the controller variable declared in application

in init() function in conroller4. Now you can call any controller easily using

MyApp.app.ContollerName.function()

Page 21: Ext JS Introduction

References

refs: [ {ref: 'feedList', selector: 'feedlist'}, {ref: 'feedCombo', selector: 'feedwindow combobox'}, { ref: 'feedWindow', selector: 'feedwindow', autoCreate: true, xtype: 'feedwindow' } ],

Page 22: Ext JS Introduction

Data Package

Page 23: Ext JS Introduction

Data StoreExt.define('AM.store.Users', { extend: 'Ext.data.Store', model: 'AM.model.User', autoLoad: true, proxy: { type: 'ajax', url: 'data/users.json', reader: { type: 'json', root: 'users', successProperty: 'success' } }});

Page 24: Ext JS Introduction

Some Samplehttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/desktop/desktop.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/feed-viewer/feed-viewer.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/calendar/index.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/live-search-grid.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/cell-editing.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/row-editing.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/charts/BarRenderer.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/tree/two-trees.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/tree/treegrid.htmlhttp://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/draw/Tiger.html

Page 25: Ext JS Introduction

URLs

• Product – http://www.sencha.com/products/extjs/

• Samples – http://www.sencha.com/products/extjs/examples/– http://docs.sencha.com/ext-js/4-1/#!/example

• Documentation– http://docs.sencha.com/ext-js/4-1/

• Videos– http://docs.sencha.com/ext-js/4-1/#!/video


Recommended