Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

extJS Cheat Sheet with the most needed stuff

Notifications You must be signed in to change notification settings

CyberT33N/extjs-cheat-sheet

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

ExtJs Cheat Sheet

Install

# We recommend extracting Ext JS in a fixed location in your "home" directory: C:\Users\Me\sencha-sdks # Windows /Users/Me/sencha-sdks # Mac OS X /home/me/sencha-sdks # Linux # After unzipping Ext JS in this folder, you should see a sub-folder such as the following (on Windows): C:\Users\Myname\sencha-sdks\ext-6.5.3 # Now that Sencha Cmd is installed and the Ext JS SDK is extracted, let's configure Sencha Cmd with this location. For example (on Windows): sencha config --prop sencha.sdk.path=C:\Users\Me\sencha-sdks --save

Initializing the Application

# To create the application, open a terminal or command prompt and create an empty directory and "cd" into it: md ~/myapp # On Windows, replace "~" with "C:\Users\Me" cd ~/myapp # From this directory, we run "sencha app init" to create the application on disk: sencha app init --ext@6.5.3 --modern MyApp

This will produce a few lines of output as the application code is generated and the necessary pieces of Ext JS are copied into the current directory. The current directory should now contain:

Debug

Get component

Ext.getCmp(id) Ext.ComponentQuery.query(attribute) 

Check user roles keycloak

Ext.getApplication().getMainView().getViewModel().get(‘user’) 

Launching the Application

sencha app watch

You will see a few lines of information as Sencha Cmd builds the application, but there are two to take note of:

. [INF] Application available at http://localhost:1841  [INF] Waiting for changes...

While app watch is running, a basic web server is serving the application directory. Now we can load http://localhost:1841 in the browser and see the application.

Sencha Cmd is also monitoring your application directory for changes. Should you make changes to the styling or JavaScript code, Sencha Cmd will detect these changes and update the necessary build outputs to keep the application rendering correctly in the browser. As your changes are detected, Sencha Cmd will log a few lines of output and (in typically a couple seconds) end with "Waiting for changes…" to let you know everything is ready.

Modifying the Application

Ext.application( name: 'MyApp', requires: [ 'Ext.MessageBox' ], launch: function ()  Ext.Msg.alert('Hello Ext JS', 'Hello! Welcome to Ext JS.'); > >);

Explanations

MVC

In an MVC architecture, most classes are either Models, Views or Controllers. The user interacts with Views, which display data held in Models. Those interactions are monitored by a Controller, which then responds to the interactions by updating the View and Model, as necessary.

The View and the Model are generally unaware of each other because the Controller has the sole responsibility of directing updates. Generally speaking, Controllers will contain most of the application logic within an MVC application. Views ideally have little (if any) business logic. Models are primarily an interface to data and contain business logic to manage changes to said data.

The goal of MVC is to clearly define the responsibilities for each class in the application. Because every class has clearly defined responsibilities, they implicitly become decoupled from the larger environment. This makes the app easier to test and maintain, and its code more reusable.

MVVM

The key difference between MVC and MVVM is that MVVM features an abstraction of a View called the ViewModel. The ViewModel coordinates the changes between a Model’s data and the View's presentation of that data using a technique called “data binding”.

The result is that the Model and framework perform as much work as possible, minimizing or eliminating application logic that directly manipulates the View.

View

ViewModel

ViewController (https://docs.sencha.com/extjs/6.5.3/classic/Ext.app.ViewController.html)

Main View

xtype

Model

Record

Store (https://docs.sencha.com/extjs/6.2.1/modern/Ext.data.Store.html)

Alias (https://docs.sencha.com/extjs/6.2.1/modern/Ext.Class.html#cfg-alias)