Ext.js – Methods

Ext.js - Methods

Following Ext.js – Methods 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.NoMethods & Description
1Ext.is.Platforms
This Ext.js – Methods 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”}]
2Ext.is.Android
This function will return true, if you are using Android operating system, else it returns false.
3Ext.is.Desktop
This function will return true, if you are using a desktop for the application, else it returns false.
4Ext.is.Phone
This function will return true, if you are using a mobile, else it returns false.
5Ext.is.iPhone
This function will return true if you are using iPhone, else it returns false.
6Ext.is.iPod
This function will return true, if you are using iPod, else it returns false.
7Ext.is.iPad
This function will return true, if you are using an iPad, else it returns false.
8Ext.is.Windows
This function will return true, if you are using Windows operating system, else it returns false.
9Ext.is.Linux
This function will return true, if you are using Linux operating system, else it returns false.
10Ext.is.Blackberry
This function will return true, if you are using Blackberry, else it returns false.
11Ext.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.NoMethods & Description
1Ext.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 in Ext.js – Methods.
2Ext.supports.GeoLocation
It checks if the device supports geolocation method or not. Internally it checks for navigator.geolocation method.
3Ext.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.
4Ext.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 in Ext.js – Methods.
5Ext.supports.Range
It checks if the browser supports document.createRange method or not inExt.js – Methods.

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.NoMethods & Description
1Ext.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;”.
2Ext.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 >”
3Ext.String.trim
This function is to trim the unwanted space in the string.Ext.String.trim(‘ hello ‘); Output – “hello”
4Ext.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”
5Ext.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.NoMethods & Description
1Ext.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”
2Version 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.
3Ext.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″.
4Browser 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.
5Ext.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
6DataType related methods −
These functions return boolean value based on the datatype of the variableExample −var a = [‘a’, ‘bc’]; var b = ‘hello’; var c = 123; var emptyVariable; var definedVariable; function extraFunction(){return true;}Ext.isArray(a);//returns trueExt.isString(b);//return trueExt.isNumber(c);//return trueExt.isEmpty(emptyVariable);//return trueExt.isEmpty(b);//return falseExt.isDefined(definedVariable);//return trueExt.isfunction(extraFunction);//return true

Learn More : Click Here

This Post Has One Comment

Leave a Reply