Posts

Showing posts from May, 2019

How to handle exception while loading datastore?

store . on ( 'loadexception' ,  function ( event ,  options ,  response ,  error ) {    alert ( "Hey, something happing." );    event . stopEvent (); });

How to decode response in Ext.js?

var   json  =  Ext . decode ( response . responseText ); Ext . Msg . alert (‘ Error ’,  json . error );

How to commit a record modification?

app . Ajax . request ({    url      :   'db/Contacts' ,    method :   'POST' ,    params :   record . getData (),    scope    :   this ,    success :   function ( response ){        if ( response . success ){            record . id  =  response . id ;            var   store  =  this . getDataview (). getStore ();            store . add ( record );            store . commitChanges ();        }    } });

How to start and stop editing a record?

Ext . define ( 'Ext.form.Basic' , {    ...    updateRecord :  function ( record ) {        var   fields  =  record . fields ,            values  =  this . getFieldValues (),            name ,             obj  = {};        fields . each ( function ( f ) {            name  =  f . name ;            if  ( name   in   values ) {                obj [ name ] =  values [ name ];            }        });     ...

How can you create HashMap in ExtJS ?

It represents a collection of a set of key and value pairs. Each key in the HashMap must be unique, the same key cannot exist twice. Access to items is provided via the key only.  Sample usage: var map = new Ext.util.HashMap(); map.add('key1', 1); map.add('key2', 2); map.add('key3', 3); map.each(function(key, value, length){     console.log(key, value, length); }); The HashMap is an unordered class, there is no guarantee when iterating over the items that they will be in any particular order. If this is required, then use a Ext.util.MixedCollection.

How can you create a singleton class in ExtJS?

To create a singleton class,just set to true, the class will be instantiated as singleton. For example: Ext.define('Logger', {     singleton: true,     log: function(msg) {         console.log(msg);     } }); Logger.log('Hello');

How can we define a constructor in a class in ExtJS?

The constructors are special method that are executed when a class is instantiated. You can use constructor to prepare the object in any way required. For example, to set up the default property values. eg: Ext.define('Test.Emp', {    config: {         name: 'Raja',         gender: 'Male'    },    constructor: function(config){        // initialize our config object        this.initConfig(config);     },     getDetails: function(){       alert('My name is ' + this.name);     } }); var honey = Ext.create("Test.Emp",{ name: 'Mary',        gender: 'Female' });

Explain a little about component query class in ExtJS?

Ext.ComponentQuery is a class which is used for searching for components. Provides searching of Components within Ext.ComponentManager (globally) or a specific Ext.container.Container on the document with a similar syntax to a CSS selector. Components can be retrieved by using their xtype. -component -gridpanel

Explain the life-cycle of a component in ExtJS?

Initialization: -The config object is applied -The base Component events are created -The component is registered in ComponentMgr -The initComponent method is called -Plugins are loaded (if applicable) -State is initialized (if applicable) -The component is rendered (if applicable) 2.  Rendering: -The beforerender event is fired -The container is set -The onRender method is called -The Component is "unhidden" -Custom class and/or style applied -The render event is fired -The afterRender method is called -The Component is hidden and/or disabled (if applicable) -Any state-specific events are initialized (if applicable) 3. Destruction : -The beforedestroy event is fired -The beforeDestroy method is called -Element and its listeners are removed -The onDestroy method is called -Component is unregistered from ComponentMgr -The destroy event is fired -Event listeners on the Component are removed

Explain about utility class 'Ext.util.TaskRunner'?

Provides the ability to execute one or more arbitrary tasks in a asynchronous manner. Generally, you can use the singleton Ext.TaskManager instead, but if needed, you can create separate instances of TaskRunner. Any number of separate tasks can be started at any time and will run independently of each other. Example usage:  // Start a simple clock task that updates a div once per second  var updateClock = function () {      Ext.fly('clock').update(new Date().format('g:i:s A'));  }  var runner = new Ext.util.TaskRunner();  var task = runner.start({      run: updateClock,      interval: 1000  } The equivalent using TaskManager:  var task = Ext.TaskManager.start({      run: updateClock,      interval: 1000  });

What is Statics in ExtJS

Any class can define static methods, which means we do not need to instantiate the class to call the method; eg: ClassName.methodName(). To declare a static method or property, simply define it as statics in its class property. List of static methods for this class. For example: Ext.define('Computer', {      statics: {          factory: function(brand) {              // 'this' in static methods refer to the class itself              return new this(brand);          }      },      constructor: function() { ... } });