Ext.js – Fonts

Ext.js – Fonts ”; Previous Next Ext.js 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”] Step 2 − Now add pictos classes as − iconCls: ”pictos pictos-home” Print Page Previous Next Advertisements ”;

Ext.js – Style

Ext.js – Style ”; Previous Next 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 Ext.js, 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 Ext.js. Sr.No 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 ) 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. Print Page Previous Next Advertisements ”;

Ext.js – Environment Setup

Ext.js – Environment Setup ”; Previous Next 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 https://www.sencha.com. You will get the trial version from the site on your registered mail id, which will be a zipped folder named ext-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-trialext6.0.1build are − Sr.No File & Description 1 ext.js This is the core file which contains all the functionalities to run the application. 2 ext-all.js This file contains all the code minified with no comments in the file. 3 ext-all-debug.js This is the unminified version of ext-all.js for debugging purpose. 4 ext-all-dev.js 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 ext-all.js 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-trialext-6.0.1buildclassictheme-classicresourcestheme-classic-all.css If you are going to use desktop application, then you can use classic themes under folder ext-6.0.1-trialext-6.0.1buildclassic If we are going to use mobile application, then you can use modern themes which can be found under folder ext-6.0.1-trialext-6.0.1buildmodern 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-trialext-6.0.1buildclassictheme-classicresourcestheme-classic-all.css” /> <script type = “text/javascript” src = “..ext-6.0.1-trialext-6.0.1buildext-all.js” > </script> <script type = “text/javascript” src = “app.js” > </script> </head> </html> You will keep ExtJS application code in app.js 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 = “https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-crisp/resources/theme-crisp-all.css” / > <script type = “text/javascript” src = “https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js”> </script> <script type = “text/javascript” src = “app.js” > </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 https://www.eclipse.org/. 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 Opera 11 and above You can use any browser for running Ext JS application. Print Page Previous Next Advertisements ”;

Ext.js – Overview

Ext.js – Overview ”; Previous Next 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 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 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. Print Page Previous Next Advertisements ”;

Ext.js – Methods

Ext.js – Methods ”; Previous Next Following are a few inbuilt functions, which are heavily used in Ext JS. Ext.is 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 Ext.is class. Sr.No Methods & Description 1 Ext.is.Platforms 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 Ext.is.Android This function will return true, if you are using Android operating system, else it returns false. 3 Ext.is.Desktop This function will return true, if you are using a desktop for the application, else it returns false. 4 Ext.is.Phone This function will return true, if you are using a mobile, else it returns false. 5 Ext.is.iPhone This function will return true if you are using iPhone, else it returns false. 6 Ext.is.iPod This function will return true, if you are using iPod, else it returns false. 7 Ext.is.iPad This function will return true, if you are using an iPad, else it returns false. 8 Ext.is.Windows This function will return true, if you are using Windows operating system, else it returns false. 9 Ext.is.Linux This function will return true, if you are using Linux operating system, else it returns false. 10 Ext.is.Blackberry This function will return true, if you are using Blackberry, else it returns false. 11 Ext.is.Mac This function will return true, if you are using Mac operating system, else it returns false. Ext.supports Class As the name indicates, this class provides information if the feature is supported by the current environment of the browser/device or not. Sr.No Methods & Description 1 Ext.supports.History It checks if the device supports HTML 5 history as window.history or not. If the device supports history, then it returns true, else false. 2 Ext.supports.GeoLocation It checks if the device supports geolocation method or not. Internally it checks for navigator.geolocation method. 3 Ext.supports.Svg It checks if the device supports HTML 5 feature scalable vector graphics (svg) method or not. Internally it checks for doc.createElementNS && !!doc.createElementNS( “http:/” + “/www.w3.org/2000/svg”, “svg”).createSVGRect. 4 Ext.supports.Canvas It checks if the device supports HTML 5 feature canvas to draw method or not. Internally it checks for doc.createElement(”canvas”).getContext and returns a value based on the output of this method. 5 Ext.supports.Range It checks if the browser supports document.createRange method or not. Ext.String Class Ext.String 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 Ext.String class to encode and decode HTML values. Sr.No Methods & Description 1 Ext.String.htmlEncode This function is used to encode html value to make it parsable. Example − Ext.String.htmlEncode(“< p > Hello World < /p >”); Output – “&lt; p &gt; Hello World &lt; /p &gt;”. 2 Ext.String.htmlDecode This function is used to decode the encoded html value. Example − Ext.String.htmlDecode(“&lt; p &gt; Hello World &lt; /p &gt;”); Output – “< p > Hello World < /p &gt” 3 Ext.String.trim This function is to trim the unwanted space in the string. Ext.String.trim(” hello ”); Output – “hello” 4 Ext.String.urlAppend This method is used to append a value in the URL string. Example − Ext.String.urlAppend(”https://www.google.com” , ”hello”); Output – “https://www.google.com?hello” Ext.String.urlAppend(”https://www.google.com?index=1” , ”hello”); Output – “https://www.google.com?index=1&hello” 5 Ext.String.toggle This function is to toggle the values between two different values. Example − var toggleString = ”ASC” toggleString = Ext.String.toggle(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 Sr.No Methods & Description 1 Ext.userAgent() 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 Ext.firefoxVersion, Ext.ieVersion, etc. Example − If you are using Firefox browser and you call the method Ext.ieVersion 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 Ext.getVersion() This function returns the current Ext JS version in use. Example − If you call Ext.getVersion(), it returns an array of values such as version, short version, etc. Ext.getVersion().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 Ext.isIE, Ext.isIE6, Ext.isFF06, and Ext.isChrome. Example − If you are using Chrome browser, then the function Ext.isChrome will return true all, otherwise it will return false. 5 Ext.typeOf() This function returns the datatype of the variable. Example − var a = 5; var b = ”hello”; Ext.typeOf(a); Output – Number Ext.typeOf(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;

Ext.js – Architecture

Ext.js – Architecture ”; Previous Next 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 ———-src ———-resources ——————-CSS files ——————-Images ———-JavaScript ——————–App Folder ——————————-Controller ————————————Contoller.js ——————————-Model ————————————Model.js ——————————-Store ————————————Store.js ——————————-View ————————————View.js ——————————-Utils ————————————Utils.js ——————————–app.js ———–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 app.js. app.js − 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. Controller.js − 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. View.js − 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. Store.js − 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. Model.js − 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. Utils.js − 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 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 developer”s effort much lesser and easier as no extra coding is required for binding data. Print Page Previous Next Advertisements ”;

Ext.js – Debugging Code

Ext.js – Debugging Ext JS code ”; Previous Next Any JavaScript code can be debugged using alert() box or console.log() or with the debug pointer in a debugger. 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 http://getfirebug.com 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 console.log() 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. Print Page Previous Next Advertisements ”;

Ext.js – Data

Ext.js – Data ”; Previous Next 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 Ext.data.Model. 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 Ext.data.Model class and we need to define the fields, their name, and mapping. Ext.define(”StudentDataModel”, { extend: ”Ext.data.Model”, 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 Ext.data.Store. 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 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. Ext.create(”Ext.data.Store”, { 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 Ext.data.proxy.Proxy. 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 Ext.create(”Ext.data.Store”, { model: ”StudentDataModel”, proxy : { type : ”rest”, actionMethods : { 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” }, } }); Print Page Previous Next Advertisements ”;

Ext.js – Layouts

Ext.js – Layouts ”; Previous Next 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. Sr.No 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 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. Print Page Previous Next Advertisements ”;

Ext.js – Home

ExtJS Tutorial PDF Version Quick Guide Resources Job Search Discussion ExtJS stands for Extended JavaScript. It is a JavaScript framework and a product of Sencha, based on YUI (Yahoo User Interface). It is basically a desktop application development platform with modern UI. This tutorial gives a complete understanding of Ext JS. This reference will take you through simple and practical approaches while learning Ext JS. Audience This tutorial has been prepared for beginners to help them understand the concepts of ExtJS to build dynamic web UI. Prerequisites For this tutorial, the reader should have prior knowledge of HTML, CSS, and JavaScript coding. It would be helpful if the reader knows the concepts of object-oriented programming and has a general idea on creating web applications. Print Page Previous Next Advertisements ”;