Posts

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' });