SlideShare a Scribd company logo
Sencha ExtJs Learning[part 2]
MVC And MVVM Architecture in ExtJs
by Irfan Maulana
MVC & MVVM
MVC (Model-View-Controller) is used by ExtJs 4.x.x or below version.
MVVM (Model-View-ViewModel) is used by ExtJs from version 5.
The key of different is ViewModel that used for data binding system.
MODEL
Model is like structure of table in Databases.
Model represent data-index and type of data will be shown.
Model normally used in store to provide data.
// sample usage
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'},
{name: 'phone', type: 'string'},
{name: 'alive', type: 'boolean'}
]
});
STORE
The Store class encapsulates a client side cache of Model objects.
Stores load data via a Proxy, and also provide functions for sorting, filtering
and querying the model instances contained within it.
// sample usage
var myStore = Ext.create('Ext.data.Store', {
model: 'User',
autoLoad: true,
proxy: {
type: 'ajax',
url: '/users.json',
reader: {
type: 'json',
root: 'users'
}
},
});
MODEL AND STORE
One instance of model can be used by many store as you need.
This will not affect to your data.
But when you use one store for many component, this will affect to your data.
When data store changed, will be affected to all component that used it.
But for some reason you will need this behavior, do as you need.
VIEW
View is component that will be shown to user.
View can be some container or component like grid, panel, combo, window, etc.
// sample usage
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
CONTROLLER
Controller is application controller.
Include Global Model, Global Store, and Global View registration here.
for private Model, Store and View use requires.
this will only loaded when needed.
Controller is listen for events (usually from views) and take some action (in
ExtJs 5 move to ViewController).
// sample usage
Ext.define('MyApp.controller.Users', {
extend: 'Ext.app.Controller',
init: function() {
}
});
VIEW CONTROLLER
Only for ExtJs 5 above.
Every view has single controller that listen even from view.
This will be more modular and manageable view.
// sample usage
Ext.define('MyApp.view.foo.FooController', {
extend: 'Ext.app.ViewController',
alias: 'controller.foo',
onBarChange: function (barTextField) {
// called by 'change' event
}
});
VIEW MODEL
The ViewModel is a class that manages data specific to the View.
It allows interested components to bind to it and be updated whenever this
data changes.
// sample usage
Ext.define('MyApp.view.TestViewModel2', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.test2',
formulas: {
x2: function (get) {
return get('x') * 2;
}
}
});
CONFIG CLASS
Config class is used for avoid too much global variable usage.
It's give you getter-setter behavior like Java done.
// sample usage
Ext.define('TEST.config.GlobalVariable',{
singleton : true,
config : {
isNewDashlite : true,
dashliteObject : null,
},
constructor : function(config){
this.initConfig(config);
}
});
HOW YOUR ARCHITECTURE WORK ?
+ Fisrt app.js will call Application.js (when use senchaCmd: config here).
+ in Application.js you defined mainController and mainView can be launch
here.
// sample Application.js
Ext.define('TNMD.Application', {
extend: 'Ext.app.Application',
name: 'TNMD',
requires : ['TNMD.config.GlobalVariable'], // this is our cofig class. please see my example config.class
controllers: [ 'AppController'], // this is our mainController
launch: function () {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [{ xtype: 'mainView' }] // this is our mainView
});
}
});
HOW YOUR ARCHITECTURE WORK ?
+ Make your controller to load mainView. (just one view, other view using
requires)
+ You can include model and store here, but dont use autoload:true for your
store.
+ Using manual load is more safety, except data for combo.
// sample controller
Ext.define('TNMD.controller.AppController', {
extend: 'Ext.app.Controller',
models: [], //global model
stores: [],
views : ['TNMD.view.MainView' ], // this is our mainView. when you include here will autoload.
init: function() {
this.control({
});
}
});
HOW YOUR ARCHITECTURE WORK ?
+ Make your controller to load mainView. (just one view, other view using
requires)
+ You can include model and store here, but dont use autoload:true for your
store.
+ Using manual load is more safety, except data for combo.
// sample mainView
Ext.define('TNMD.view.MainView', {
extend: 'Ext.container.Container',
xtype: 'mainView',
itemId: 'mainView',
requires: [ 'TNMD.viewController.MainController', 'TNMD.view.FilterPanel', 'TNMD.view.ContentPanel'],
controller: 'mainController', //this is our view Controller
layout : 'border',
listeners:{afterrender: ‘onAfterRender’} //call event in ViewController
items:[{xtype : 'filterPanel', region : 'west', width : 250,},
{xtype : 'contentPanel', region : 'center',}]
});
HOW YOUR ARCHITECTURE WORK ?
+ Listing all event from view in viewController.
// sample of mainViewController
Ext.define('TNMD.viewController.MainController', {
extend: 'Ext.app.ViewController',
alias: 'controller.mainController',
onAfterRender: function(){
alert(“call after render”);
}
});
Contact me on :
Email : mazipanneh@gmail.com
Blog : mazipanneh.wordpress.com
Thanks for your attention.
Presented by : Irfan Maulana

More Related Content

Viewers also liked

Ext Js introduction and new features in Ext Js 6
Ext Js introduction and new features in Ext Js 6Ext Js introduction and new features in Ext Js 6
Ext Js introduction and new features in Ext Js 6
Sushil Shinde
 
CSS Frameworks: Faster Layout, Consistent Results
CSS Frameworks: Faster Layout, Consistent ResultsCSS Frameworks: Faster Layout, Consistent Results
CSS Frameworks: Faster Layout, Consistent Results
Steve Hong
 
Ext js 6
Ext js 6Ext js 6
Ext js 6
Manav Gupta
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
Irfan Maulana
 
conjoon - The Open Source Webmail Client
conjoon - The Open Source Webmail Clientconjoon - The Open Source Webmail Client
conjoon - The Open Source Webmail Client
Thorsten Suckow-Homberg
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
Irfan Maulana
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JSikhwanhayat
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The Machine
Irfan Maulana
 
email clients and webmail (presentation)
email clients and webmail   (presentation)email clients and webmail   (presentation)
email clients and webmail (presentation)kay2
 
Journey To The Front End World - Part1 - The Skeleton
Journey To The Front End World - Part1 - The SkeletonJourney To The Front End World - Part1 - The Skeleton
Journey To The Front End World - Part1 - The Skeleton
Irfan Maulana
 
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha ProjectsGuidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
AmitaSuri
 

Viewers also liked (12)

Extjs
ExtjsExtjs
Extjs
 
Ext Js introduction and new features in Ext Js 6
Ext Js introduction and new features in Ext Js 6Ext Js introduction and new features in Ext Js 6
Ext Js introduction and new features in Ext Js 6
 
CSS Frameworks: Faster Layout, Consistent Results
CSS Frameworks: Faster Layout, Consistent ResultsCSS Frameworks: Faster Layout, Consistent Results
CSS Frameworks: Faster Layout, Consistent Results
 
Ext js 6
Ext js 6Ext js 6
Ext js 6
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
 
conjoon - The Open Source Webmail Client
conjoon - The Open Source Webmail Clientconjoon - The Open Source Webmail Client
conjoon - The Open Source Webmail Client
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The Machine
 
email clients and webmail (presentation)
email clients and webmail   (presentation)email clients and webmail   (presentation)
email clients and webmail (presentation)
 
Journey To The Front End World - Part1 - The Skeleton
Journey To The Front End World - Part1 - The SkeletonJourney To The Front End World - Part1 - The Skeleton
Journey To The Front End World - Part1 - The Skeleton
 
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha ProjectsGuidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
 

Similar to Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]

WPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaWPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA Austria
Rainer Stropek
 
Angular Presentation
Angular PresentationAngular Presentation
Angular PresentationAdam Moore
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
icubesystem
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
Sencha
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
Bipin
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
Pratchaya Suputsopon
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive
 
Models, controllers and views
Models, controllers and viewsModels, controllers and views
Models, controllers and viewspriestc
 
Mvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senjaMvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senja
alifha12
 
MVC Training Part 2
MVC Training Part 2MVC Training Part 2
MVC Training Part 2
Lee Englestone
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Omnia Helmi
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
vrluckyin
 
RequireJS
RequireJSRequireJS
RequireJS
Tim Doherty
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Knoldus Inc.
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 

Similar to Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH] (20)

WPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA AustriaWPF and Prism 4.1 Workshop at BASTA Austria
WPF and Prism 4.1 Workshop at BASTA Austria
 
Angular Presentation
Angular PresentationAngular Presentation
Angular Presentation
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
 
mean stack
mean stackmean stack
mean stack
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Models, controllers and views
Models, controllers and viewsModels, controllers and views
Models, controllers and views
 
Mvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senjaMvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senja
 
MVC Training Part 2
MVC Training Part 2MVC Training Part 2
MVC Training Part 2
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
 
RequireJS
RequireJSRequireJS
RequireJS
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
Ext JS Introduction
Ext JS IntroductionExt JS Introduction
Ext JS Introduction
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 

More from Irfan Maulana

Modern Web - an Introduction
Modern Web - an IntroductionModern Web - an Introduction
Modern Web - an Introduction
Irfan Maulana
 
Unit Testing for Frontend Code at Blibli.com
Unit Testing for Frontend Code at Blibli.comUnit Testing for Frontend Code at Blibli.com
Unit Testing for Frontend Code at Blibli.com
Irfan Maulana
 
Programmer In Startup Era
Programmer In Startup EraProgrammer In Startup Era
Programmer In Startup Era
Irfan Maulana
 
Bliblidotcom - Evolusi Frontend Development di Bliblidotcom
Bliblidotcom - Evolusi Frontend Development di BliblidotcomBliblidotcom - Evolusi Frontend Development di Bliblidotcom
Bliblidotcom - Evolusi Frontend Development di Bliblidotcom
Irfan Maulana
 
Bliblidotcom - Tech In Asia PDC 2017 Takeaway
Bliblidotcom - Tech In Asia PDC 2017 TakeawayBliblidotcom - Tech In Asia PDC 2017 Takeaway
Bliblidotcom - Tech In Asia PDC 2017 Takeaway
Irfan Maulana
 
Bliblidotcom - AMP And PWA
Bliblidotcom - AMP And PWABliblidotcom - AMP And PWA
Bliblidotcom - AMP And PWA
Irfan Maulana
 
Angular - The Return of The King
Angular - The Return of The KingAngular - The Return of The King
Angular - The Return of The King
Irfan Maulana
 
How to Become Rockstar Programmer
How to Become Rockstar ProgrammerHow to Become Rockstar Programmer
How to Become Rockstar Programmer
Irfan Maulana
 
Bliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS IntroductionBliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS Introduction
Irfan Maulana
 
Bliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSSBliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSS
Irfan Maulana
 
PHP Indonesia - Understanding UI UX from Developer Side
PHP Indonesia - Understanding UI UX from Developer SidePHP Indonesia - Understanding UI UX from Developer Side
PHP Indonesia - Understanding UI UX from Developer Side
Irfan Maulana
 
JakartaJS - How I Learn Javascript From Basic
JakartaJS - How I Learn Javascript From BasicJakartaJS - How I Learn Javascript From Basic
JakartaJS - How I Learn Javascript From Basic
Irfan Maulana
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
Irfan Maulana
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
Irfan Maulana
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
Irfan Maulana
 
Irfan Maulana - Career Journey
Irfan Maulana - Career JourneyIrfan Maulana - Career Journey
Irfan Maulana - Career Journey
Irfan Maulana
 

More from Irfan Maulana (16)

Modern Web - an Introduction
Modern Web - an IntroductionModern Web - an Introduction
Modern Web - an Introduction
 
Unit Testing for Frontend Code at Blibli.com
Unit Testing for Frontend Code at Blibli.comUnit Testing for Frontend Code at Blibli.com
Unit Testing for Frontend Code at Blibli.com
 
Programmer In Startup Era
Programmer In Startup EraProgrammer In Startup Era
Programmer In Startup Era
 
Bliblidotcom - Evolusi Frontend Development di Bliblidotcom
Bliblidotcom - Evolusi Frontend Development di BliblidotcomBliblidotcom - Evolusi Frontend Development di Bliblidotcom
Bliblidotcom - Evolusi Frontend Development di Bliblidotcom
 
Bliblidotcom - Tech In Asia PDC 2017 Takeaway
Bliblidotcom - Tech In Asia PDC 2017 TakeawayBliblidotcom - Tech In Asia PDC 2017 Takeaway
Bliblidotcom - Tech In Asia PDC 2017 Takeaway
 
Bliblidotcom - AMP And PWA
Bliblidotcom - AMP And PWABliblidotcom - AMP And PWA
Bliblidotcom - AMP And PWA
 
Angular - The Return of The King
Angular - The Return of The KingAngular - The Return of The King
Angular - The Return of The King
 
How to Become Rockstar Programmer
How to Become Rockstar ProgrammerHow to Become Rockstar Programmer
How to Become Rockstar Programmer
 
Bliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS IntroductionBliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS Introduction
 
Bliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSSBliblidotcom - Reintroduction BEM CSS
Bliblidotcom - Reintroduction BEM CSS
 
PHP Indonesia - Understanding UI UX from Developer Side
PHP Indonesia - Understanding UI UX from Developer SidePHP Indonesia - Understanding UI UX from Developer Side
PHP Indonesia - Understanding UI UX from Developer Side
 
JakartaJS - How I Learn Javascript From Basic
JakartaJS - How I Learn Javascript From BasicJakartaJS - How I Learn Javascript From Basic
JakartaJS - How I Learn Javascript From Basic
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Irfan Maulana - Career Journey
Irfan Maulana - Career JourneyIrfan Maulana - Career Journey
Irfan Maulana - Career Journey
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]

  • 1. Sencha ExtJs Learning[part 2] MVC And MVVM Architecture in ExtJs by Irfan Maulana
  • 2. MVC & MVVM MVC (Model-View-Controller) is used by ExtJs 4.x.x or below version. MVVM (Model-View-ViewModel) is used by ExtJs from version 5. The key of different is ViewModel that used for data binding system.
  • 3. MODEL Model is like structure of table in Databases. Model represent data-index and type of data will be shown. Model normally used in store to provide data. // sample usage Ext.define('User', { extend: 'Ext.data.Model', fields: [ {name: 'name', type: 'string'}, {name: 'age', type: 'int'}, {name: 'phone', type: 'string'}, {name: 'alive', type: 'boolean'} ] });
  • 4. STORE The Store class encapsulates a client side cache of Model objects. Stores load data via a Proxy, and also provide functions for sorting, filtering and querying the model instances contained within it. // sample usage var myStore = Ext.create('Ext.data.Store', { model: 'User', autoLoad: true, proxy: { type: 'ajax', url: '/users.json', reader: { type: 'json', root: 'users' } }, });
  • 5. MODEL AND STORE One instance of model can be used by many store as you need. This will not affect to your data. But when you use one store for many component, this will affect to your data. When data store changed, will be affected to all component that used it. But for some reason you will need this behavior, do as you need.
  • 6. VIEW View is component that will be shown to user. View can be some container or component like grid, panel, combo, window, etc. // sample usage Ext.create('Ext.grid.Panel', { title: 'Simpsons', store: Ext.data.StoreManager.lookup('simpsonsStore'), columns: [ { text: 'Name', dataIndex: 'name' }, { text: 'Email', dataIndex: 'email', flex: 1 }, { text: 'Phone', dataIndex: 'phone' } ], height: 200, width: 400, renderTo: Ext.getBody() });
  • 7. CONTROLLER Controller is application controller. Include Global Model, Global Store, and Global View registration here. for private Model, Store and View use requires. this will only loaded when needed. Controller is listen for events (usually from views) and take some action (in ExtJs 5 move to ViewController). // sample usage Ext.define('MyApp.controller.Users', { extend: 'Ext.app.Controller', init: function() { } });
  • 8. VIEW CONTROLLER Only for ExtJs 5 above. Every view has single controller that listen even from view. This will be more modular and manageable view. // sample usage Ext.define('MyApp.view.foo.FooController', { extend: 'Ext.app.ViewController', alias: 'controller.foo', onBarChange: function (barTextField) { // called by 'change' event } });
  • 9. VIEW MODEL The ViewModel is a class that manages data specific to the View. It allows interested components to bind to it and be updated whenever this data changes. // sample usage Ext.define('MyApp.view.TestViewModel2', { extend: 'Ext.app.ViewModel', alias: 'viewmodel.test2', formulas: { x2: function (get) { return get('x') * 2; } } });
  • 10. CONFIG CLASS Config class is used for avoid too much global variable usage. It's give you getter-setter behavior like Java done. // sample usage Ext.define('TEST.config.GlobalVariable',{ singleton : true, config : { isNewDashlite : true, dashliteObject : null, }, constructor : function(config){ this.initConfig(config); } });
  • 11. HOW YOUR ARCHITECTURE WORK ? + Fisrt app.js will call Application.js (when use senchaCmd: config here). + in Application.js you defined mainController and mainView can be launch here. // sample Application.js Ext.define('TNMD.Application', { extend: 'Ext.app.Application', name: 'TNMD', requires : ['TNMD.config.GlobalVariable'], // this is our cofig class. please see my example config.class controllers: [ 'AppController'], // this is our mainController launch: function () { Ext.create('Ext.container.Viewport', { layout: 'fit', items: [{ xtype: 'mainView' }] // this is our mainView }); } });
  • 12. HOW YOUR ARCHITECTURE WORK ? + Make your controller to load mainView. (just one view, other view using requires) + You can include model and store here, but dont use autoload:true for your store. + Using manual load is more safety, except data for combo. // sample controller Ext.define('TNMD.controller.AppController', { extend: 'Ext.app.Controller', models: [], //global model stores: [], views : ['TNMD.view.MainView' ], // this is our mainView. when you include here will autoload. init: function() { this.control({ }); } });
  • 13. HOW YOUR ARCHITECTURE WORK ? + Make your controller to load mainView. (just one view, other view using requires) + You can include model and store here, but dont use autoload:true for your store. + Using manual load is more safety, except data for combo. // sample mainView Ext.define('TNMD.view.MainView', { extend: 'Ext.container.Container', xtype: 'mainView', itemId: 'mainView', requires: [ 'TNMD.viewController.MainController', 'TNMD.view.FilterPanel', 'TNMD.view.ContentPanel'], controller: 'mainController', //this is our view Controller layout : 'border', listeners:{afterrender: ‘onAfterRender’} //call event in ViewController items:[{xtype : 'filterPanel', region : 'west', width : 250,}, {xtype : 'contentPanel', region : 'center',}] });
  • 14. HOW YOUR ARCHITECTURE WORK ? + Listing all event from view in viewController. // sample of mainViewController Ext.define('TNMD.viewController.MainController', { extend: 'Ext.app.ViewController', alias: 'controller.mainController', onAfterRender: function(){ alert(“call after render”); } });
  • 15. Contact me on : Email : mazipanneh@gmail.com Blog : mazipanneh.wordpress.com Thanks for your attention. Presented by : Irfan Maulana