0% found this document useful (0 votes)
56 views50 pages

Ext JS Quick Guide for Beginners

Ext.js is a popular JavaScript framework for building rich web applications. It provides UI widgets like grids, charts, and forms and supports cross-browser functionality. Ext.js uses MVC/MVVM architecture and its latest version can be used to build both desktop and mobile applications. To set up Ext.js, developers download library files, include them in an HTML file along with app.js which contains application code, and use CDNs or IDE plugins for development. Popular editors for Ext.js development include Notepad++ and Visual Studio Code.

Uploaded by

Aashish
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views50 pages

Ext JS Quick Guide for Beginners

Ext.js is a popular JavaScript framework for building rich web applications. It provides UI widgets like grids, charts, and forms and supports cross-browser functionality. Ext.js uses MVC/MVVM architecture and its latest version can be used to build both desktop and mobile applications. To set up Ext.js, developers download library files, include them in an HTML file along with app.js which contains application code, and use CDNs or IDE plugins for development. Popular editors for Ext.js development include Notepad++ and Visual Studio Code.

Uploaded by

Aashish
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

5/31/2021 Ext.

js - Quick Guide - Tutorialspoint

[Link] - Quick Guide

[Link] - Overview

Ext JS is a popular JavaScript framework which provides rich UI for building web applications with
cross-browser functionality. Ext JS is basically used for creating desktop applications. It supports all
the modern browsers such as IE6+, FF, Chrome, Safari 6+, Opera 12+, etc. Whereas another
product of Sencha, Sencha Touch is used for mobile applications.

Ext JS is based on MVC/MVVM architecture. The latest version of Ext JS 6 is a single platform,
which can be used for both desktop and mobile application without having different code for
different platform.

History

Ext JS 1.1

The first version of Ext JS was developed by Jack Slocum in 2006. It was a set of utility classes,
which is an extension of YUI. He named the library as YUI-ext.

Ext JS 2.0

Ext JS version 2.0 was released in 2007. This version had a new API documentation for desktop
application with limited features. This version doesn’t have backward compatibility with previous
version of Ext JS.

Ext JS 3.0

Ext JS version 3.0 was released in 2009. This version added new features as chart and list view but
at the cost of speed. It had backward compatibility with version 2.0.

Ext JS 4.0

After the release of Ext JS 3, the developers of Ext JS had the major challenge of ramping up the
speed. Ext JS version 4.0 was released in 2011. It had the complete revised structure, which was
followed by MVC architecture and a speedy application.

Ext JS 5.0

[Link] 1/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Ext JS version 5.0 was released in 2014. The major change in this release was to change the MVC
architecture to MVVM architecture. It includes the ability to build desktop apps on touch-enabled
devices, two-way data binding, responsive layouts, and many more features.

Ext JS 6.0

Ext JS 6 merges the Ext JS (for desktop application) and Sencha Touch (for mobile application)
framework.

Features

Following are the highlighted features of Ext JS.


Customizable UI widgets with collection of rich UI such as grids, pivot grids, forms, charts,
trees.
Code compatibility of new versions with the older one.

A flexible layout manager helps to organize the display of data and content across multiple
browsers, devices, and screen sizes.
Advance data package decouples the UI widgets from the data layer. The data package
allows client-side collection of data using highly functional models that enable features
such as sorting and filtering.
It is protocol agnostic, and can access data from any back-end source.

Customizable Themes Ext JS widgets are available in multiple out-of-the-box themes that
are consistent across platforms.

Benefits

Sencha Ext JS is the leading standard for business-grade web application development. Ext JS
provides the tools necessary to build robust applications for desktop and tablets.
Streamlines cross-platform development across desktops, tablets, and smartphones - for
both modern and legacy browsers.

Increases the productivity of development teams by integrating into enterprise


development environments via IDE plugins.
Reduces the cost of web application development.

Empowers the teams to create apps with a compelling user experience.


Offers a set of widgets to easily make a powerful UI.
Follows MVC architecture, hence the code is highly readable.

Limitations

[Link] 2/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

The size of the library is large, around 500 KB, which makes initial loading time more and
makes application slow.
HTML is full of tags that makes it complex and difficult to debug.
According to general public license policy, it is free for open source applications but paid for
commercial applications.
Sometimes for loading even simple things require few lines of coding, which is simpler in
plain html or JQuery.
Need quite experienced developer for developing Ext JS applications.

Tools

Following are the tools provided by Sencha used for Ext JS application development mainly at the
production level.

Sencha CMD

Sencha CMD is a tool which provides the features of Ext JS code minification, scaffolding, and
production build generation.

Sencha IDE Plugins

Sencha IDE plugins integrates Sencha frameworks into IntelliJ, WebStorm IDEs, which helps in
improving the developer’s productivity by providing features such as code completion, code
inspection, code navigation, code generation, code refactoring, template creation, spell-checking,
etc.

Sencha Inspector

Sencha Inspector is a debugging tool which helps the debugger to debug any issue while
development.

[Link] - Environment Setup

Local Environment Setup

This section guides you on how to download and set up Ext JS on your machine. Please follow the
steps to set up the environment.

Downloading Library Files

Download the trial version of Ext JS library files from Sencha [Link] . You will
get the trial version from the site on your registered mail id, which will be a zipped folder named ext-

[Link] 3/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

6.0.1-trial.

Unzip the folder and you will find various JavaScript and CSS files, which you will include in our
application. We will mostly include the following files −
JavaScript Files − JS file which you can find under the folder \ext-6.0.1-trial\ext6.0.1\build are −

[Link] File & Description

1 [Link]
This is the core file which contains all the functionalities to run the application.

2 [Link]
This file contains all the code minified with no comments in the file.

3
[Link]
This is the unminified version of [Link] for debugging purpose.

4 [Link]
This file is also unminified and is used for development purpose as it contains all the
comments and console logs to check any errors/issue.

5 [Link]
This file is used for production purpose mostly as it is much smaller than any other.

You can add these files to your projects JS folder or you can provide a direct path where the file
resides in your system.
CSS Files − There are number of theme-based files, which you can find under folder \ext6.0.1-
trial\ext-6.0.1\build\classic\theme-classic\resources\[Link]
If you are going to use desktop application, then you can use classic themes under folder
\ext-6.0.1-trial\ext-6.0.1\build\classic
If we are going to use mobile application, then you can use modern themes which can be
found under folder \ext-6.0.1-trial\ext-6.0.1\build\modern
The following library files will be added in an Ext JS application.

<html>
<head>
<link rel = "stylesheet" type = "text/css"
href = "..\ext-6.0.1-trial\ext-6.0.1\build\classic\theme-classic\resources\th
[Link] 4/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

<script type = "text/javascript"


src = "..\ext-6.0.1-trial\ext-6.0.1\build\[Link]" > </script>
<script type = "text/javascript" src = "[Link]" > </script>
</head>
</html>

You will keep ExtJS application code in [Link] file.

CDN Setup

CDN is content delivery network with which you do not need to download the Ext JS library files,
instead you can directly add CDN link for ExtJS to your program as follows −

<html>
<head>
<link rel = "stylesheet" type = "text/css"
href = "[Link]
<script type = "text/javascript"
src = "[Link] </scri
<script type = "text/javascript" src = "[Link]" > </script>
</head>
</html>

Popular Editors

As it is a JavaScript framework, which is used for developing web applications, in our project we will
have HTML, JS files. To write our Ext JS programs, we will need a text editor. There are even
multiple IDEs available in the market. But for now, we can consider one of the following −
Notepad − On Windows machine, you can use any simple text editor such as Notepad
(Recommended for this tutorial), Notepad++, sublime.

Eclipse − It is an IDE developed by the eclipse open-source community and can be


downloaded from [Link] .

Browser

Ext JS supports cross-browser compatibility, it supports all major browsers such as −


IE 6 and above
Firefox 3.6 and above
Chrome10 and above
Safari 4 and above

[Link] 5/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Opera 11 and above


You can use any browser for running Ext JS application.

[Link] - Naming Convention

Naming convention is a set of rule to be followed for identifiers. It makes the code more readable
and understandable to other programmers as well.
Naming convention in Ext JS follows the standard JavaScript convention, which is not mandatory
but a good practice to follow. It should follow the camel case syntax for naming the class, method,
variable and properties.

If the name is combined with two words, the second word will start with an uppercase letter always.
For example, doLayout(), StudentForm, firstName, etc.

Name Convention

Class Name It should start with an uppercase letter, followed by camel case. For example,
StudentClass

Method Name It should start with a lowercase letter, followed by camel case. For example,
doLayout()

Variable Name It should start with a lowercase letter, followed by camel case. For example,
firstName

Constant Name It should be in uppercase only. For example, COUNT, MAX_VALUE

Property Name It should start with a lowercase letter, followed by camel case. For example,
enableColumnResize = true

[Link] - Architecture

Ext JS follows MVC/ MVVM architecture.

MVC – Model View Controller architecture (version 4)

MVVM – Model View Viewmodel (version 5)


This architecture is not mandatory for the program, however, it is a best practice to follow this
structure to make your code highly maintainable and organized.

Project Structure with Ext JS App

[Link] 6/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

----------src
----------resources
-------------------CSS files
-------------------Images
----------JavaScript
--------------------App Folder
-------------------------------Controller
------------------------------------[Link]
-------------------------------Model
------------------------------------[Link]
-------------------------------Store
------------------------------------[Link]
-------------------------------View
------------------------------------[Link]
-------------------------------Utils
------------------------------------[Link]
--------------------------------[Link]
-----------HTML files

Ext JS app folder will reside in JavaScript folder of your project.

The App will contain controller, view, model, store, and utility files with [Link].
[Link] − The main file from where the flow of program will start, which should be included in the
main HTML file using <script> tag. App calls the controller of application for the rest of the
functionality.
[Link] − It is the controller file of Ext JS MVC architecture. This contains all the control of the
application, the events listeners, and most of the functionality of the code. It has the path defined
for all the other files used in that application such as store, view, model, require, mixins.
[Link] − It contains the interface part of the application, which shows up to the user. Ext JS uses
various UI rich views, which can be extended and customized here according to the requirement.
[Link] − It contains the data locally cached which is to be rendered on the view with the help of
model objects. Store fetches the data using proxies which has the path defined for services to fetch
the backend data.

[Link] − It contains the objects which binds the store data to view. It has the mapping of backend
data objects to the view dataIndex. The data is fetched with the help of store.
[Link] − It is not included in MVC architecture but a best practice to use to make the code clean,
less complex, and more readable. We can write methods in this file and call them in the controller
or the view renderer wherever required. It is helpful for code reusability purpose as well.

In MVVM architecture, the controller is replaced by ViewModel.

ViewModel − It basically mediates the changes between view and model. It binds the data from the
model to the view. At the same time, it does not have any direct interaction with the view. It has only

[Link] 7/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

knowledge of the model.

How It Works

For example, if we are using one model object at two-three places in UI. If we change the value at
one place of UI, we can see without even saving that change. The value of model changes and so
gets reflected in all the places in the UI, wherever the model is used.

It makes the developers’ effort much lesser and easier as no extra coding is required for binding
data.

[Link] - First Program

This chapter lists down the steps to write the first Hello World program in Ext JS.

Step 1

Create an [Link] page in the editor of our choice. Include the required library files in the head
section of html page as follows.

[Link]

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: 'helloWorldPanel',
height: 200,
width: 600,
title: 'Hello world',
html: 'First Ext JS Hello World Program'
});
});
</script>
</head>

<body>
[Link] 8/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

<div id = "helloWorldPanel" />


</body>
</html>

Explanation

[Link]() method will be called once the Ext JS is ready to render the Ext JS
elements.

[Link]() method is used to create an object in Ext JS. Here we are creating an object of
simple panel class [Link].
[Link] is the predefined class in Ext JS for creating a panel.

Every Ext JS class has different properties to perform some basic functionalities.
[Link] class has various properties such as −

renderTo is the element where this panel has to render. 'helloWorldPanel' is the div id in
[Link] file.

Height and width properties are for customizing the size of the panel.
Title property is to provide the title to the panel.

Html property is the html content to be shown in the panel.

Step 2

Open the [Link] file in a standard browser and you will get the following output on the browser.

Hello world

[Link] - Class System

Ext JS is a JavaScript framework having functionalities of object oriented programming. Ext is the
namespace, which encapsulates all the classes in Ext JS.

Defining a Class in Ext JS

Ext provides more than 300 classes, which we can use for various functionalities.
[Link]() is used for defining the classes in Ext JS.

Syntax

[Link](class name, class members/properties, callback function);

[Link] 9/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Class name is the name of the class according to app structure. For example,
[Link] [Link].

Class properties/members defines the behavior of class.


Callback function is optional. It is called when the class has loaded properly.

Example of Ext JS Class Definition

[Link]([Link], {
extend : '[Link]',
id : 'studentsDetailsGrid',
store : 'StudentsDetailsGridStore',
renderTo : 'studentsDetailsRenderDiv',
layout : 'fit',

columns : [{
text : 'Student Name',
dataIndex : 'studentName'
},{
text : 'ID',
dataIndex : 'studentId'
},{
text : 'Department',
dataIndex : 'department'
}]
});

Creating Objects

As like other OOPS based languages, we can create objects in Ext JS as well.

Following are the different ways of creating objects in Ext JS.

Using new keyword

var studentObject = new student();


[Link]();

Using [Link]()

[Link]('[Link]', {
renderTo : 'helloWorldPanel',
height : 100,
width : 100,
title : 'Hello world',
[Link] 10/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

html : 'First Ext JS Hello World Program'


});

Inheritance in Ext JS

Inheritance is the principle of using functionality defined in class A into class B.

In Ext JS, inheritance can be done using two methods −

[Link]

[Link]([Link], {
extend : '[Link]',
...
});

Here, our custom class StudentDetailsGrid is using the basic features of Ext JS class GridPanel.

Using Mixins

Mixins is a different way of using class A in class B without extend.

mixins : {
commons : '[Link]'
},

Mixins are added in the controller where we declare all the other classes such as store, view, etc. In
this way, we can call DepartmentUtils class and use its functions in the controller or in this
application.

[Link] - Containers

Container in Ext JS is the component where we can add other container or child components.
These containers can have multiple layout to arrange the components in the containers. We can
add or remove the components from the container and from its child elements.
[Link] is the base class for all the containers in Ext JS.

[Link] 11/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Description

1 Components inside Container


This example shows how to define the components inside a container

2 Container inside container


This example shows how to define a container inside a container with other components

There are various type of containers [Link], [Link], [Link] and


[Link] are frequently used containers in Ext JS. Below are the example which
shows how to use these containers.

[Link]. Type of Containers & Description

1 [Link]
This example shows a [Link] container

2 [Link]
This example shows a [Link] container

3 [Link]
This example shows a [Link] container

4 [Link]
This example shows a [Link] container

[Link] 12/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] - Layouts

Layout is the way the elements are arranged in a container. It can be horizontal, vertical, or any
other. Ext JS has a different layout defined in its library but we can always write custom layouts as
well.

[Link] 13/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Layout & Description

1 Absolute
This layout allows to position the items using XY coordinates in the container.

2 Accordion
This layout allows to place all the items in stack fashion (one on top of the other) inside
the container.

3 Anchor
This layout gives the privilege to the user to specify the size of each element with
respect to the container size.

4 Border
In this layout various panels are nested and separated by borders.

5 Auto
This is the default layout that decides the layout of the elements based on the number of
elements.

6 Card(TabPanel)
This layout arranges different components in tab fashion. Tabs will be displayed on top
of the container. Every time only one tab is visible and each tab is considered as a
different component.

7 Card(Wizard)
In this layout, every time the elements come for full container space. There is a bottom
tool bar in the wizard for navigation.

8 Column
This layout is to show multiple columns in the container. We can define a fixed or
percentage width to the columns. The percentage width will be calculated based on the
full size of the container.

9 Fit
In this layout, the container is filled with a single panel. When there is no specific
requirement related to the layout, then this layout is used.

10 Table
[Link] 14/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

As the name implies, this layout arranges the components in a container in the HTML
table format.

11 vBox
This layout allows the element to be distributed in a vertical manner. This is one of the
most used layout.

12 hBox
This layout allows the element to be distributed in a horizontal manner.

[Link] - Components

ExtJS UI is made up of one or many widgets called Components. Ext Js has various UI
components defined that can be customised as per your requirements.

[Link] 15/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Methods & Description

1 Grid
Grid component can be used to show the data in a tabular format.

2 Form
Form widget is to get the data from the user.

3 Message Box
Message box is basically used to show data in the form of alert box.

4 Chart
Charts are used to represent data in pictorial format.

5 Tool tip
Tool tip is used to show some basic information when any event occurs.

6 Window
This UI widget is to create a window, which should pop up when any event occurs.

7 HTML editor
HTML Editor is one of the very useful UI component, which is used for styling the data
that the user enters in terms of fonts, color, size, etc.

8 Progress bar
Shows the progress of the backend work.

[Link] - Drag and Drop

Drag and drop feature is one of the powerful features added to make the developer’s task easy. A
drag operation, essentially, is a click gesture on some UI element, while the mouse button is held
down and the mouse is moved. A drop operation occurs when the mouse button is released after a
drag operation.

Syntax

Adding drag and drop class to the draggable targets.


[Link] 16/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

var dd = [Link]('[Link]', el, 'imagesDDGroup', {


isTarget: false
});

Adding drag and drop target class to drappable target.

var mainTarget = [Link]('[Link]', 'mainRoom', 'imagesDDGroup', {


ignoreSelf: false
});

Example

Following is a simple example.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link] ({
launch: function() {
var images = [Link]('images').select('img');
[Link]([Link], function(el) {
var dd = [Link]('[Link]', el, 'imagesDDGroup', {
isTarget: false
});
});
}
});
var mainTarget = [Link]('[Link]', 'mainRoom', 'imagesDDGroup', {
ignoreSelf: false
});
</script>

<style>
#content {
width:600px;
height:400px;
padding:10px;
border:1px solid #000;
[Link] 17/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

}
#images {
float:left;
width:40%;
height:100%;
border:1px solid Black;
background-color:rgba(222, 222, 222, 1.0);
}
#mainRoom {
float:left;
width:55%;
height:100%;
margin-left:15px;
border:1px solid Black;
background-color:rgba(222, 222, 222, 1.0);
}
.image {
width:64px;
height:64px;
margin:10px;
cursor:pointer;
border:1px solid Black;
display: inline-block;
}
</style>
</head>

<body>
<div id = "content">
<div id = "images">
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
<img src = "/extjs/images/[Link]" class = "image" />
</div>
<div id = "mainRoom"></div>
</div>
</body>
</html>

The above program will produce the following result −


[Link] 18/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

With the help of drag and drop in Extjs, we can move data from grid to grid and grid to form.
Following are the examples of moving data between grids and forms.

Drag and drop - Grid to Grid


drag and drop - Grid to Form

[Link] - Themes

[Link] provides a number of themes to be used in your applications. You can add a different theme
in place of a classic theme and see the difference in the output. This is done simply by replacing
the theme CSS file as explained ahead.

Neptune Theme

Consider your very first Hello World application. Remove the following CSS from the application.

[Link]

Add the following CSS to use the Neptune theme.

[Link]

[Link] 19/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

To see the effect, try the following program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: 'helloWorldPanel',
height: 200,
width: 600,
title: 'Hello world',
html: 'First Ext JS Hello World Program'
});
});
</script>
</head>

<body>
<div id = "helloWorldPanel" />
</body>
</html>

The above program will produce the following result −

H ll ld

Crisp Theme

Consider your very first Hello World application. Remove the following CSS from the application.

[Link]

Add the following CSS to use the Neptune theme.

[Link]
[Link] 20/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

To see the effect, try the following program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]
<script type = "text/javascript">
[Link](function() {
[Link]('[Link]', {
renderTo: 'helloWorldPanel',
height: 200,
width: 600,
title: 'Hello world',
html: 'First Ext JS Hello World Program'
});
});
</script>
</head>

<body>
<div id = "helloWorldPanel" />
</body>
</html>

The above program will produce the following result −

H ll ld

Triton Theme

Consider your very first Hello World application. Remove the following CSS from the application.

[Link]

Add the following CSS to use the Triton theme.

[Link]

[Link] 21/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

To see the effect, try the following program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: 'helloWorldPanel',
height: 200,
width: 600,
title: 'Hello world',
html: 'First Ext JS Hello World Program'
});
});
</script>
</head>

<body>
<div id = "helloWorldPanel" />
</body>
</html>

The above program will produce the following result −

Gray Theme

Consider your very first Hello World application. Remove the following CSS from the application.

[Link]

Add the following CSS to use the Gray theme.

[Link] 22/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link]

To see the effect, try the following program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: 'helloWorldPanel',
height: 200,
width: 600,
title: 'Hello world',
html: 'First Ext JS Hello World Program'
});
});
</script>
</head>

<body>
<div id = "helloWorldPanel" />
</body>
</html>

The above program will produce the following result −

Hello world

[Link] - Custom Events and listeners

Events are something which get fired when something happens to the class. For example, when a
button is getting clicked or before/after the element is rendered.

Methods of Writing Events

[Link] 23/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Built-in events using listeners


Attaching events later
Custom events

Built-in Events Using Listeners

Ext JS provides listener property for writing events and custom events in Ext JS files.

Writing listener in Ext JS


We will add the listener in the previous program itself by adding a listen property to the panel.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: [Link]('helloWorldPanel'),
text: 'My Button',

listeners: {
click: function() {
[Link]('Alert box', 'Button is clicked');
}
}
});
});
</script>
</head>

<body>
<p> Please click the button to see event listener </p>
<div id = 'helloWorldPanel' /> <!-- panel will be rendered here-- >
</body>
</html>

The above program will produce the following result −

[Link] 24/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Please click the button to see event listener:

My Button

This way we can also write multiple events in listeners property.

Multiple Events in the Same Listener

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
[Link]('tag2').hide()
[Link]('[Link]', {
renderTo: [Link]('helloWorldPanel'),
text: 'My Button',

listeners: {
click: function() {
[Link]();
},
hide: function() {
[Link]('tag1').hide();
[Link]('tag2').show();
}
}
});
});
</script>
</head>

<body>
<div id = "tag1">Please click the button to see event listener.</div>
<div id = "tag2">The button was clicked and now it is hidden.</div>
<div id = 'helloWorldPanel' /> <!-- panel will be rendered here-- >
</body>
</html>

[Link] 25/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Please click the button to see event listener.

My Button

Attaching an Event Later

In the previous method of writing events, we have written events in listeners at the time of creating
elements. The other way is to attach events.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
var button = [Link]('[Link]', {
renderTo: [Link]('helloWorldPanel'),
text: 'My Button'
});

// This way we can attach event to the button after the button is created.
[Link]('click', function() {
[Link]('Alert box', 'Button is clicked');
});
});
</script>
</head>

<body>
<p> Please click the button to see event listener </p>
<div id = 'helloWorldPanel' /> <!-- panel will be rendered here-- >
</body>
</html>

The above program will produce the following result −

Please click the button to see event listener:

My Button

[Link] 26/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Custom Events

We can write custom events in Ext JS and fire the events with fireEvent method. Following example
explains how to write custom events.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
var button = [Link]('[Link]', {
renderTo: [Link]('helloWorldPanel'),
text: 'My Button',

listeners: {
myEvent: function(button) {
[Link]('Alert box', 'My custom event is called');
}
}
});
[Link](function() {
[Link]('myEvent');
}, 5000);
});
</script>
</head>

<body>
<p> The event will be called after 5 seconds when the page is loaded. </p>
<div id = 'helloWorldPanel' /> <!-- panel will be rendered here-- >
</body>
</html>

Once the page is loaded and the document is ready, the UI page with a button will appear and as
we are firing an event after 5 secs, the document is ready. The alert box will appear after 5
seconds.

[Link] 27/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint
My Button My custom event is called

OK

Here, we have written the custom event 'myEvent' and we are firing events as
[Link](eventName);

[Link] - Data

Data package is used for loading and saving all the data in the application.
Data package has numerous number of classes but the most important classes are −
Model
Store
Proxy

Model

The base class for model is [Link]. It represents an entity in an application. It binds the
store data to view. It has mapping of backend data objects to the view dataIndex. The data is
fetched with the help of store.

Creating a Model

For creating a model, we need to extend [Link] class and we need to define the fields,
their name, and mapping.

[Link]('StudentDataModel', {
extend: '[Link]',
fields: [
{name: 'name', mapping : 'name'},
{name: 'age', mapping : 'age'},
{name: 'marks', mapping : 'marks'}
]
});

Here, the name should be the same as the dataIndex, which we declare in the view and the
mapping should match the data, either static or dynamic from the database, which is to be fetched
using store.

Store
The base class for store is [Link]. It contains the data locally cached, which is to be
rendered on view with the help of model objects. Store fetches the data using proxies, which has

[Link] 28/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

the path defined for services to fetch the backend data.


Store data can be fetched in two ways - static or dynamic.

Static store

For static store, we will have all the data present in the store as shown in the following code.

[Link]('[Link]', {
model: 'StudentDataModel',
data: [
{ name : "Asha", age : "16", marks : "90" },
{ name : "Vinit", age : "18", marks : "95" },
{ name : "Anand", age : "20", marks : "68" },
{ name : "Niharika", age : "21", marks : "86" },
{ name : "Manali", age : "22", marks : "57" }
];
});

Dynamic Store

Dynamic data can be fetched using proxy. We can have proxy which can fetch data from Ajax,
Rest, and Json.

Proxy

The base class for proxy is [Link]. Proxy is used by Models and Stores to handle the
loading and saving of Model data.
There are two types of proxies
Client Proxy
Server Proxy

Client Proxy

Client proxies include Memory and Local Storage using HTML5 local storage.

Server Proxy

Server proxies handle data from the remote server using Ajax, Json data, and Rest service.
Defining proxies in the server

[Link]('[Link]', {
model: 'StudentDataModel',
proxy : {
type : 'rest',
actionMethods : {
[Link] 29/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

read : 'POST' // Get or Post type based on requirement


},
url : 'restUrlPathOrJsonFilePath', // here we have to include the rest URL path
// which fetches data from database or Json file path where the data is stored
reader: {
type : 'json', // the type of data which is fetched is of JSON type
root : 'data'
},
}
});

[Link] - Fonts

[Link] provides the facility to use different font packages. Font packages are used to add different
classes for icons available in the package.
Font-Awesome
Font-Pictos

Font-Awesome
ExtJS new theme, Triton, has an inbuilt font family font-awesome included in the framework itself,
hence we do not need any explicit requirement for the font-awesome stylesheet.
Following is an example of using Font-Awesome classes in the Triton theme.
Font-Awesome with Triton theme

When we are using any other theme apart from Triton, we need or require to add a stylesheet for
font-awesome explicitly.
Following is an example of using Font-Awesome classes without the Triton theme.

Font-Awesome with normal theme(Any theme other then Triton theme)

Font-Pictos
Font-pictos is not included in the framework for ExtJS, hence we have to require the same. Only
licenced users of Sencha will have the benefit to use font-pictos.

Steps to Add Font-Pictos

Step 1 − Require font-pictos class using the following command.

"requires": ["font-pictos"]

[Link] 30/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Step 2 − Now add pictos classes as −

iconCls: 'pictos pictos-home'

[Link] - Style

Application Styling refers to user adjustment of the look and feel of the components. These
adjustments may include: color, color gradients, font, margins/padding, etc. Ext JS 6 has a new way
of styling the application.
It uses SCSS for styling. SCSS is a more dynamic way of writing the CSS code. We can write the
variables in our stylesheet with the help of this. However, a browser cannot understand SCSS. It
can only understand CSS, hence all SCSS files should get compiled into CSS to a production-
ready code.
Thus, SCSS file is called preprocessor files. In [Link], compilation is done through Sencha CMD
tool. Sencha CMD compiles it manually only once using the following command.

sencha app build [development]

Global_CSS is the main CSS file, which has all SCSS variables associated with it in ExtJS that can
be used in our application for customizing our theme by providing different value based on our
need.
Following are some of the CSS variables available in the Global_CSS in [Link].

[Link] 31/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Variable & Description

1
$base-color
$base-color: color (e.g. $base-color : #808080)
This base color is to be used throughout the theme.

2
$base-gradient
$base-gradient: string (e.g. $base-gradient : 'matte')
This base gradient is to be used throughout the theme.

3 $body-background-color
$body-background-color: color (e.g. $body-background-color : #808080)
Background color to apply to the body element. If set to transparent or 'none', no
background-color style will be set on the body element.

4
$color
$color : color (e.g. $color : #808080)
This default text color is to be used throughout the theme.

5
$font-family
$font-family : string (e.g. $font-family : arial)
This default font-family is to be used throughout the theme.

6 $font-size
$font-size : number (e.g. $font-size : 9px )
This default font-size is to be used throughout the theme.

7 $font-weight

$font-weight : string/number (e.g. $font-weight : normal )


This default font-weight is to be used throughout the theme.

8
$font-weight-bold
$font-weight-bold : string/number (e.g. $font-weight-bold : bold )
[Link] 32/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

This default font-weight for bold font is to be used throughout the theme.

9 $include-chrome
$include-chrome : boolean (e.g. $include-chrome : true)
True to include Chrome specific rules.

10 $include-ff

$include-ff : boolean (e.g. $include-ff : true)


True to include Firefox specific rules.

11
$include-ie
$include-ie : boolean (e.g. $include-ie : true)
True to include Internet Explorer specific rules for IE9 and lower.

12
$include-opera
$include-opera : boolean (e.g. $include-opera : true)
True to include Opera specific rules.

13 $include-safari

$include-safari : boolean (e.g. $include-safari : true)


True to include Opera specific rules.

14
$include-webkit
$include-webkit : boolean (e.g. $include-webkit : true)
True to include Webkit specific rules.

[Link] - Drawing

Drawing package in ExtJS enables you to draw general purpose graphics. This can be used for
graphics that work on all browsers and mobile devices.

[Link] 33/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Drawing

1 Circle
This graphics is used to create a circulare shape.

2 Rectangle
This graphics is used to create a rectanglar shape.

3 Arc
This graphics is used to create an arc shape.

4 Ellipse
This graphics is used to create an ellipse shape.

5 EllipticalArc
This graphics is used to create an elliptical arc shape.

6 Image
This graphics is used to add an image to your application.

7 Path
This graphics is used to create a free path.

8 Text
This graphics is used to add any text to your application.

9 Translate after render


This property is used to move the starting point in your container, after the graphic is
rendered. It can be used with any graphics.

10 Rotation
This property is used to add a rotation to the drawing added. It can be used with any
graphics.

11 Square
This graphic is used to create a square.

[Link] 34/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] - Localization

It is always best to communicate with the users in the language they understand and prefer. Extjs
localization package supports over 40 languages such as German, French, Korean, Chinese, etc. It
is very simple to implement the locale in ExtJs. You’ll find all of the bundled locale files in the
override folder of the ext-locale package. Locale files just overrides that tells Ext JS to replace the
default English values of certain components.
The following program is to show the month in different locale to see the effect. Try the following
program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function() {
var monthArray = [Link]([Link], function (e) { return
var ds = [Link]('[Link]', {
fields: ['month'],
remoteSort: true,
pageSize: 6,

proxy: {
type: 'memory',
enablePaging: true,
data: monthArray,
reader: {type: 'array'}
}
});
[Link]('[Link]', {
renderTo: 'grid',
id : 'gridId',
width: 600,
height: 200,
title:'Month Browser',

[Link] 35/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

columns:[{
text: 'Month of the year',
dataIndex: 'month',
width: 300
}],
store: ds,
bbar: [Link]('[Link]', {
pageSize: 6,
store: ds,
displayInfo: true
})
});
[Link]('gridId').getStore().load();
});
</script>
</head>

<body>
<div id = "grid" />
</body>
</html>

The above program will produce the following result

Month Browser

For using different locale other than English, we would need to add the locale specific file in our
program. Here we are using
[Link] for French. You can use
different locale for different languages such as
[Link] for korean, etc.
The following program is to show the date picker in Korean locale to see the effect. Try the
following program.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]
<script type = "text/javascript"
src = "[Link]

[Link] 36/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

<script type = "text/javascript">


[Link](function() {
[Link]('[Link]', {
renderTo: 'datePicker'
});
});
</script>
</head>

<body>
<div id = "datePicker" />
</body>
</html>

The above program will produce the following result −

5월 2021

Following table lists the few locales available in ExtJS and the main file locale URL to be changed.

Locale Language Locale URL

ko Korean [Link]

fr French [Link]

es Spanish [Link]

ja Japanese [Link]

it Italian [Link]

ru Russian [Link]

zh_CN Simplifies
[Link]
Chinese

[Link] - Accessibility

In general accessibility means availability, the content is accessible means the content is available.

In software terms, the application is accessible means the application is available for all. Here, all
means the persons with disabilities, the visually impaired or those who use screen readers to use a
computer or those who prefer to navigate using the keyboard instead of using a mouse. navigation
with keyboard instead of using a mouse.
Applications which are accessible are called ARIA (Accessible Rich Internet Applications).
[Link] 37/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Accessibility in Ext JS
Ext JS is designed to keep this in mind that it should work with all keyboard navigations. It has built-
in tab indexing and focus-ability, and it is always on by default so we do not need to add any
property to enable this functionality.
This functionality allows all keyboard-enabled components to interact with the user when tabbed
into. For example, we can use tab for moving on to the next component instead of a mouse. Same
way, we can use shift+tab for moving backward and use enter on the keyboard to click, etc.

Focus Styling and Tabs

Focus is inbuilt in Extjs when using keystroke for tabbing.


Following example shows how to the style changes, when the focus changes with the tabs.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link](function(){
[Link]('[Link]', {
renderTo: [Link]('button1'),
text: 'Button1',

listeners: {
click: function() {
[Link]('Alert box', 'Button 1 is clicked');
}
}
});
[Link]('[Link]', {
renderTo: [Link]('button2'),
text: 'Button2',

listeners: {
click: function() {
[Link]('Alert box', 'Button 2 is clicked');
}
}
});

[Link] 38/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link]('[Link]', {
renderTo: [Link]('button3'),
text: 'Button3',

listeners: {
click: function() {
[Link]('Alert box', 'Button 3 is clicked');
}
}
});
});
</script>
</head>

<body> <p>Please click the button to see event listener:</p>


<span id = "button3"/>
<span id = "button2"/>
<span id = "button1"/>
</body>
</html>

To see the effect, use tab for moving from the next button and shft+tab for focusing backward. Use
enter and see how the focused button's related alert would pop up.

Please click the button to see event listener:

Button1 Button2 Button3

ARIA Theme

ExtJS provides the theme aria for the visually impaired.


Following example shows the aria theme which is easily accessible for the visually impaired.

Live Demo
<!DOCTYPE html>
<html>
<head>
<link href = "[Link]
rel = "stylesheet" />
<script type = "text/javascript"
src = "[Link]

<script type = "text/javascript">


[Link]([
'[Link].*',

[Link] 39/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

'[Link].*'
]);

// Creation of data model


[Link]('StudentDataModel', {
extend: '[Link]',
fields: [
{name: 'name', mapping : 'name'},
{name: 'age', mapping : 'age'},
{name: 'marks', mapping : 'marks'}
]
});

[Link](function() {
// Store data
var myData = [
{ name : "Asha", age : "16", marks : "90" },
{ name : "Vinit", age : "18", marks : "95" },
{ name : "Anand", age : "20", marks : "68" },
{ name : "Niharika", age : "21", marks : "86" },
{ name : "Manali", age : "22", marks : "57" }
];

// Creation of first grid store


var firstGridStore = [Link]('[Link]', {
model: 'StudentDataModel',
data: myData
});

// Creation of first grid


var firstGrid = [Link]('[Link]', {
store : firstGridStore,
columns :
[{
header: "Student Name",
dataIndex: 'name',
id : 'name',
flex: 1,
sortable: true
},{
header: "Age",
dataIndex: 'age',
flex: .5,
sortable: true
},{
header: "Marks",

[Link] 40/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

dataIndex: 'marks',
flex: .5,
sortable: true
}],
stripeRows : true,
title : 'First Grid',
margins : '0 2 0 0'
});

// Creation of a panel to show both the grids.


var displayPanel = [Link]('[Link]', {
width : 600,
height : 200,

layout : {
type: 'hbox',
align: 'stretch',
padding: 5
},
renderTo : 'panel',
defaults : { flex : 1 },
items : [
firstGrid
]
});
});
</script>
</head>

<body>
<div id = "panel" > </div>
</body>
</html>

The above program will produce the following result. You can use tab and mouse up and down
keys for moving the focus across the grid and the theme is basically for the visually impaired
people.

[Link] - Debugging Ext JS code

Any JavaScript code can be debugged using alert() box or [Link]() or with the debug pointer
in a debugger.
[Link] 41/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Alert Box

Place an alert box in the code where you want to check the flow or any variable value. For
example, alert('message to show' + variable);

Development/Debugging Tool

Debugger is the most important tool for any developer to check the issue and error in the code
while developing.
Ext JS is a JavaScript framework, hence it can be easily debugged using developer tools provided
by or specific to different browsers. All the major browsers have their developer tools available to
test and debug JavaScript code.
Popular debuggers are IE development tool for IE, firebug for firefox, and chrome development tool
for Chrome browser.
Chrome debugger comes with Chrome browser, however, firebug has to be installed specifically as
it doesn’t come as a package with firefox.
Here is a link to install firebug for firefox browser [Link]
The shortcut to open the development tool in Windows OS is F12 keyboard key.

Debugging JS Code in Debugger


There are two ways to debug JavaScript code.
The first way, is to place [Link]() in the code and see the value of the log, which will
be printed in the console of the development tool.
The second way is by using breakpoints in the development tool. Following is the process.

Open the file in all the available scripts under script tag.
Now place a breakpoint to the line you want to debug.
Run the application in the browser.
Now, whenever the code flow will reach this line, it will break the code and stay
there until the user runs the code by keys F6 (go to the next line of the code), F7
(go inside the function) or F8 (go to the next breakpoint or run the code if there is
no more breakpoints) based on the flow you want to debug.
You can select the variable or the function you want to see the value of.
You can use the console to check the value or to check some changes in the
browser itself.

[Link] - Methods

[Link] 42/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

Following are a few inbuilt functions, which are heavily used in Ext JS.

[Link] Class
This class checks the platform you are using, whether it is a phone or a desktop, a mac or Windows
operating system. These are the following methods related to [Link] class.

[Link] 43/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Methods & Description

1 [Link]

This function returns the platform available for this version.


For example, when you run the following function, it returns something like this −

[Object { property = "platform", regex = RegExp, identity = "iPhone"},


Object { property = "platform", regex = RegExp, identity = "iPod"},
Object { property = "userAgent", regex = RegExp, identity = "iPad"},
Object { property = "userAgent", regex = RegExp, identity = "Blackberry"},
Object { property = "userAgent", regex = RegExp, identity = "Android"},
Object { property = "platform", regex = RegExp, identity = "Mac"},
Object { property = "platform", regex = RegExp, identity = "Windows"},
Object { property = "platform", regex = RegExp, identity = "Linux"}]

2
[Link]
This function will return true, if you are using Android operating system, else it returns
false.

3 [Link]
This function will return true, if you are using a desktop for the application, else it returns
false.

4 [Link]
This function will return true, if you are using a mobile, else it returns false.

5 [Link]

This function will return true if you are using iPhone, else it returns false.

6 [Link]

This function will return true, if you are using iPod, else it returns false.

7
[Link]
This function will return true, if you are using an iPad, else it returns false.

8
[Link]
[Link] 44/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

This function will return true, if you are using Windows operating system, else it returns
false.

9
[Link]
This function will return true, if you are using Linux operating system, else it returns false.

10
[Link]
This function will return true, if you are using Blackberry, else it returns false.

11 [Link]
This function will return true, if you are using Mac operating system, else it returns false.

[Link] Class

As the name indicates, this class provides information if the feature is supported by the current
environment of the browser/device or not.

[Link] 45/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Methods & Description

1 [Link]
It checks if the device supports HTML 5 history as [Link] or not. If the device
supports history, then it returns true, else false.

2 [Link]

It checks if the device supports geolocation method or not. Internally it checks for
[Link] method.

3 [Link]
It checks if the device supports HTML 5 feature scalable vector graphics (svg) method or
not. Internally it checks for [Link] && !![Link]( "http:/" +
"/[Link]/2000/svg", "svg").createSVGRect.

4 [Link]
It checks if the device supports HTML 5 feature canvas to draw method or not. Internally
it checks for [Link]('canvas').getContext and returns a value based on the
output of this method.

5 [Link]
It checks if the browser supports [Link] method or not.

[Link] Class
[Link] class has various methods to work with string data. The most used methods are
encoding decoding, trim, toggle, urlAppend, etc.
Encoding Decoding function − These are the functions available in [Link] class to encode
and decode HTML values.

[Link] 46/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Methods & Description

1 [Link]
This function is used to encode html value to make it parsable.
Example −

[Link]("< p > Hello World < /p >");


Output - "&lt; p &gt; Hello World &lt; /p &gt;".

2 [Link]
This function is used to decode the encoded html value.
Example −

[Link]("&lt; p &gt; Hello World &lt; /p &gt;");


Output - "< p > Hello World < /p >"

3 [Link]
This function is to trim the unwanted space in the string.

[Link](' hello ');


Output – "hello"

4 [Link]

This method is used to append a value in the URL string.


Example −

[Link]('[Link] , 'hello');
Output - "[Link]
[Link]('[Link] , 'hello');
Output – "[Link]

5 [Link]
This function is to toggle the values between two different values.
Example −
[Link] 47/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

var toggleString = 'ASC'


toggleString = [Link](a, 'ASC', 'DESC');
Output – DESC as toggleString had value ASC. Now again, if we
print the same we will get toggleString = “ASC” this time, as
it had value 'DESC'.
It is similar to ternary operator
toggleString = ((toggleString =='ASC')? 'DESC' : 'ASC' );

Miscellaneous Methods

[Link] 48/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link] Methods & Description

1 [Link]()
This function gives information about browser userAgent. UserAgent is to identify the
browser and the operating system to the web server.
Example − If you are working in Mozilla, it returns something like: "mozilla/5.0 (windows
nt 6.1; wow64; rv:43.0) gecko/20100101 firefox/43.0"

2 Version related function


This function returns the version of the browser currently in use, if the function is called
related to IE. In Firefox browser, it returns 0. These functions are [Link],
[Link], etc.
Example − If you are using Firefox browser and you call the method [Link] for
fetching the version of IE, then it returns 0. If you are using the same method in IE
browser, then it will return the version you are using such as 8, 9, etc.

3 [Link]()

This function returns the current Ext JS version in use.


Example − If you call [Link](), it returns an array of values such as version,
short version, etc.
[Link]().version returns the current version of Ext JS used in the program, such
as “4.2.2".

4 Browser related functions


These functions return Boolean values based on the browser in use. These methods are
[Link], Ext.isIE6, Ext.isFF06, and [Link].
Example − If you are using Chrome browser, then the function [Link] will return
true all, otherwise it will return false.

5 [Link]()
This function returns the datatype of the variable.
Example −

var a = 5;
var b = 'hello';
[Link](a);
Output – Number
[Link] 49/50
5/31/2021 [Link] - Quick Guide - Tutorialspoint

[Link](b);
Output - String

6
DataType related methods − These functions return boolean value based on the
datatype of the variable
Example −

var a = ['a', 'bc'];


var b = 'hello';
var c = 123;
var emptyVariable;
var definedVariable;
function extraFunction(){return true;}

[Link](a); //returns true

[Link](b); //return true

[Link](c); //return true

[Link](emptyVariable); //return true

[Link](b); //return false

[Link](definedVariable); //return true

[Link](extraFunction); //return true

[Link] 50/50

Common questions

Powered by AI

The Sencha Inspector is a debugging tool that assists developers in identifying and resolving issues during the development process. It provides insights into the code execution and enables developers to pinpoint problems in the application efficiently .

Setting breakpoints in Ext JS is a crucial part of the debugging process. By placing breakpoints at specific lines within the code, developers can pause execution and examine the current state. This step-by-step analysis allows for careful inspection of variables and function execution, helping to identify and resolve errors efficiently. Breakpoints are managed using development tools and are essential for understanding complex application logic .

Utility scripts like 'Utils.js' provide significant benefits in large-scale Ext JS development by facilitating code cleanliness, reusability, and organization. By abstracting common methods into utility scripts, developers can create a modular code structure that reduces complexity and increases maintainability. This approach promotes best practices and streamlines development processes across extensive applications .

In Ext JS, the MVVM architecture differs from the MVC pattern primarily in that the ViewModel replaces the controller. The ViewModel mediates changes between the view and the model, binding data from the model to the view without having direct interaction with the view. This separation enhances data binding and allows for a more decoupled architecture by keeping the view and the model independent from each other .

Ext JS's code inspection features improve developer productivity by identifying potential errors, suggesting corrections, and allowing developers to navigate large codebases efficiently. These features help maintain code quality and reduce debugging time by effectively catching issues before they escalate .

'View.js' in Ext JS MVC architecture is dedicated to the interface part of the application. It is responsible for presenting data to the user and managing user interface interactions. Ext JS allows views to be extended and customized, providing rich UI components and enhancing user interface development by making it more flexible and visually appealing .

In Ext JS, built-in events are predefined events provided by the framework, which can be leveraged by adding listeners to respond to particular user interactions or system triggers. Custom events, on the other hand, are user-defined events that allow developers to create specific interactions tailored to the application's needs. Both types of events can be managed within the listener configuration, allowing for sophisticated event handling .

Using themes like Neptune or Triton in Ext JS applications provides a quick and effective way to enhance application aesthetics. These themes offer pre-defined stylistic elements that can be easily integrated, significantly improving the user interface appearance without requiring extensive custom CSS development. Themes help maintain a consistent design language across the application and reduce time spent on styling .

The 'ext-all.js' file in Ext JS is primarily used for production environments due to its smaller size and minified code, which improves load times. In contrast, 'ext-all-debug.js' and 'ext-all-dev.js' are used for development and debugging purposes. 'ext-all-debug.js' contains unminified code suitable for debugging, while 'ext-all-dev.js' includes additional comments and console logs to help developers identify errors or issues during development .

In Ext JS's MVC architecture, the 'Store' component is responsible for managing the data locally cached to be rendered on the view. It fetches data using proxies, which have defined paths for services to access backend data. The 'Store' acts as an intermediary, ensuring that the view has access to the data it needs to display .

You might also like