ExtReact Docs Help

Introduction

The documentation for the ExtReact product diverges somewhat from the documentation of other Sencha products. The sections below describe documentation for all products except where indicated as unique to ExtReact.

Terms, Icons, and Labels

Many classes have shortcut names used when creating (instantiating) a class with a configuration object. The shortcut name is referred to as an alias (or xtype if the class extends Ext.Component). The alias/xtype is listed next to the class name of applicable classes for quick reference.

ExtReact component classes list the configurable name prominently at the top of the API class doc followed by the fully-qualified class name.

Access Levels

Framework classes or their members may be specified as private or protected. Else, the class / member is public. Public, protected, and private are access descriptors used to convey how and when the class or class member should be used.

Member Types

Member Syntax

Below is an example class member that we can disect to show the syntax of a class member (the lookupComponent method as viewed from the Ext.button.Button class in this case).

lookupComponent ( item ) : Ext.Component
protected

Called when a raw config object is added to this container either during initialization of the items config, or when new items are added), or {@link #insert inserted.

This method converts the passed object into an instanced child component.

This may be overridden in subclasses when special processing needs to be applied to child creation.

Parameters

item :  Object

The config object being added.

Returns
Ext.Component

The component to be added.

Let's look at each part of the member row:

Member Flags

The API documentation uses a number of flags to further commnicate the class member's function and intent. The label may be represented by a text label, an abbreviation, or an icon.

Class Icons

- Indicates a framework class

- A singleton framework class. *See the singleton flag for more information

- A component-type framework class (any class within the Ext JS framework that extends Ext.Component)

- Indicates that the class, member, or guide is new in the currently viewed version

Member Icons

- Indicates a class member of type config

Or in the case of an ExtReact component class this indicates a member of type prop

- Indicates a class member of type property

- Indicates a class member of type method

- Indicates a class member of type event

- Indicates a class member of type theme variable

- Indicates a class member of type theme mixin

- Indicates that the class, member, or guide is new in the currently viewed version

Class Member Quick-Nav Menu

Just below the class name on an API doc page is a row of buttons corresponding to the types of members owned by the current class. Each button shows a count of members by type (this count is updated as filters are applied). Clicking the button will navigate you to that member section. Hovering over the member-type button will reveal a popup menu of all members of that type for quick navigation.

Getter and Setter Methods

Getting and setter methods that correlate to a class config option will show up in the methods section as well as in the configs section of both the API doc and the member-type menus just beneath the config they work with. The getter and setter method documentation will be found in the config row for easy reference.

ExtReact component classes do not hoist the getter / setter methods into the prop. All methods will be described in the Methods section

History Bar

Your page history is kept in localstorage and displayed (using the available real estate) just below the top title bar. By default, the only search results shown are the pages matching the product / version you're currently viewing. You can expand what is displayed by clicking on the button on the right-hand side of the history bar and choosing the "All" radio option. This will show all recent pages in the history bar for all products / versions.

Within the history config menu you will also see a listing of your recent page visits. The results are filtered by the "Current Product / Version" and "All" radio options. Clicking on the button will clear the history bar as well as the history kept in local storage.

If "All" is selected in the history config menu the checkbox option for "Show product details in the history bar" will be enabled. When checked, the product/version for each historic page will show alongside the page name in the history bar. Hovering the cursor over the page names in the history bar will also show the product/version as a tooltip.

Search and Filters

Both API docs and guides can be searched for using the search field at the top of the page.

On API doc pages there is also a filter input field that filters the member rows using the filter string. In addition to filtering by string you can filter the class members by access level, inheritance, and read only. This is done using the checkboxes at the top of the page.

The checkbox at the bottom of the API class navigation tree filters the class list to include or exclude private classes.

Clicking on an empty search field will show your last 10 searches for quick navigation.

API Doc Class Metadata

Each API doc page (with the exception of Javascript primitives pages) has a menu view of metadata relating to that class. This metadata view will have one or more of the following:

Expanding and Collapsing Examples and Class Members

Runnable examples (Fiddles) are expanded on a page by default. You can collapse and expand example code blocks individually using the arrow on the top-left of the code block. You can also toggle the collapse state of all examples using the toggle button on the top-right of the page. The toggle-all state will be remembered between page loads.

Class members are collapsed on a page by default. You can expand and collapse members using the arrow icon on the left of the member row or globally using the expand / collapse all toggle button top-right.

Desktop -vs- Mobile View

Viewing the docs on narrower screens or browsers will result in a view optimized for a smaller form factor. The primary differences between the desktop and "mobile" view are:

Viewing the Class Source

The class source can be viewed by clicking on the class name at the top of an API doc page. The source for class members can be viewed by clicking on the "view source" link on the right-hand side of the member row.

ExtReact 6.7.0


top

Summary

Wraps a collection of validation error responses and provides convenient functions for accessing and errors for specific fields.

Usually this class does not need to be instantiated directly - instances are instead created automatically when validate on a model instance:

 // Validate some existing model instance - in this case it returned 2 failures
 // messages

 var errors = myModel.validate();
 errors.isValid(); //false

 errors.length; //2
 errors.getByField('name');  // [{field: 'name',  message: 'must be present'}]
 errors.getByField('title'); // [{field: 'title', message: 'is too short'}]
No members found using the current filters

configs

Optional Configs

allowFunctions : Boolean

Configure as true if the addAll function should add function references to the collection.

defaultSortDirection : String

The default sort direction to use if one is not specified.

Defaults to:

"ASC"

listeners : Object

A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once.

DOM events from Ext JS Ext.Component

While some Ext JS Component classes export selected DOM events (e.g. "click", "mouseover" etc), this is usually only done when extra value can be added. For example the DataView's itemclick event passing the node clicked on. To access DOM events directly from a child element of a Component, we need to specify the element option to identify the Component property to add a DOM listener to:

new Ext.panel.Panel({
    width: 400,
    height: 200,
    dockedItems: [{
        xtype: 'toolbar'
    }],
    listeners: {
        click: {
            element: 'el', //bind to the underlying el property on the panel
            fn: function(){ console.log('click el'); }
        },
        dblclick: {
            element: 'body', //bind to the underlying body property on the panel
            fn: function(){ console.log('dblclick body'); }
        }
    }
});

setListeners ( listeners )

An alias for addListener. In versions prior to 5.1, listeners had a generated setter which could be called to add listeners. In 5.1 the listeners config is not processed using the config system and has no generated setter, so this method is provided for backward compatibility. The preferred way of adding listeners is to use the on method.

Parameters

listeners :  Object

The listeners

multiSortLimit : Number

The maximum number of sorters which may be applied to this Sortable when using the "multi" insertion position when adding sorters.

New sorters added using the "multi" insertion position are inserted at the top of the sorters list becoming the new primary sort key.

If the sorters collection has grown to longer then multiSortLimit, then it is trimmed.

Defaults to:

3

sorters : Ext.util.Sorter[] / Object[]

The initial set of Ext.util.Sorter.

sorters: [{
    property: 'age',
    direction: 'DESC'
}, {
    property: 'firstName',
    direction: 'ASC'
}]

Defaults to:

null

getSorters : Ext.util.Sorter[] / Object[]

Returns the value of sorters

Returns

Ext.util.Sorter[] / Object[]

setSorters (sorters)

Sets the value of sorters

Parameters

sorters :  Ext.util.Sorter[] / Object[]

sortRoot : String

The property in each item that contains the data to sort.

properties

Instance Properties

$eventOptions
private pri

Matches options property names within a listeners specification object - property names which are never used as event names.

Defaults to:

{
    scope: 1,
    delay: 1,
    buffer: 1,
    onFrame: 1,
    single: 1,
    args: 1,
    destroyable: 1,
    priority: 1,
    order: 1
}

$vetoClearingPrototypeOnDestroy
private pri

We don't want the base destructor to clear the prototype because our destroyObservable handler must be called the very last. It will take care of the prototype after completing Observable destruction sequence.

Defaults to:

true

autoGenId : Boolean
private pri

true indicates an id was auto-generated rather than provided by configuration.

Defaults to:

false

Available since: 6.7.0

captureArgs
private pri

Defaults to:

Super.captureArgs

eventsSuspended
private pri

Initial suspended call count. Incremented when suspendEvents is called, decremented when resumeEvents is called.

Defaults to:

0

generation
private pri

Mutation counter which is incremented upon add and remove.

Defaults to:

0

hasListeners : Object
readonly ro

This object holds a key for any event that has a listener. The listener may be set directly on the instance, or on its class or a super class (via observe) or on the MVC EventBus. The values of this object are truthy (a non-zero number) and falsy (0 or undefined). They do not represent an exact count of listeners. The value for an event is truthy if the event must be fired and is falsy if there is no need to fire the event.

The intended use of this property is to avoid the expense of fireEvent calls when there are no listeners. This can be particularly helpful when one would otherwise have to call fireEvent hundreds or thousands of times. It is used like this:

 if (this.hasListeners.foo) {
     this.fireEvent('foo', this, arg1);
 }

indexGeneration
private pri

Mutation counter for the index map which is synchronized with the collection's mutation counter when the index map is interrogated and found to be out of sync and needed a rebuild.

Defaults to:

0

isMixedCollection : Boolean

true in this class to identify an object as an instantiated MixedCollection, or subclass thereof.

Defaults to:

true

isObservable : Boolean

true in this class to identify an object as an instantiated Observable, or subclass thereof.

Defaults to:

true

isSortable : Boolean

true in this class to identify an object as an instantiated Sortable, or subclass thereof.

Defaults to:

true

methods

Instance Methods

_addDeclaredListeners ( listeners ) : Boolean
private pri

Adds declarative listeners as nested arrays of listener objects.

Parameters

listeners :  Array

Returns

:Boolean

true if any listeners were added

_sort ( property, [dir], [fn] )
private pri

Performs the actual sorting based on a direction and a sorting function. Internally, this creates a temporary array of all items in the MixedCollection, sorts it and then writes the sorted array data back into this.items and this.keys

Parameters

property :  String

Property to sort by ('key', 'value', or 'index')

dir :  String (optional)

Direction to sort 'ASC' or 'DESC'. Defaults to 'ASC'.

fn :  Function (optional)

Comparison function that defines the sort order. Defaults to sorting by numeric value.

add ( key, [obj] ) : Object

Adds an item to the collection. Fires the event-add event when complete.

Available since: 1.1.0

Parameters

key :  String/Object

The key to associate with the item, or the new item.

If a getKey implementation was specified for this MixedCollection, or if the key of the stored items is in a property called id, the MixedCollection will be able to derive the key for the new item. In this case just pass the new item in this parameter.

obj :  Object (optional)

The item to add.

Note that when adding a value that is iterable, it must be wrapped in brackets, i.e.:

c.add([[1, 2]]);

This will be needed for any value that is iterable, i.e., an array, arguments object, HTML collections, etc.

Returns

:Object

The item added.

addAll ( objs )

Adds all elements of an Array or an Object to the collection.

Available since: 1.1.0

Parameters

objs :  Object/Array

An Object containing properties which will be added to the collection, or an Array of values, each of which are added to the collection. Functions references will be added to the collection if allowFunctions has been set to true.

addListener ( eventName, [fn], [scope], [options], [order] ) : Object
chainable ch

The on method is shorthand for addListener.

Appends an event handler to this object. For example:

myGridPanel.on("itemclick", this.onItemClick, this);

The method also allows for a single argument to be passed which is a config object containing properties which specify multiple events. For example:

myGridPanel.on({
    cellclick: this.onCellClick,
    select: this.onSelect,
    viewready: this.onViewReady,
    scope: this // Important. Ensure "this" is correct during handler execution
});

One can also specify options for each event handler separately:

myGridPanel.on({
    cellclick: {fn: this.onCellClick, scope: this, single: true},
    viewready: {fn: panel.onViewReady, scope: panel}
});

Names of methods in a specified scope may also be used:

myGridPanel.on({
    cellclick: {fn: 'onCellClick', scope: this, single: true},
    viewready: {fn: 'onViewReady', scope: panel}
});

Parameters

eventName :  String/Object

The name of the event to listen for. May also be an object who's property names are event names.

fn :  Function/String (optional)

The method the event invokes or the name of the method within the specified scope. Will be called with arguments given to Ext.util.Observable#fireEvent plus the options parameter described below.

scope :  Object (optional)

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

options :  Object (optional)

An object containing handler configuration.

Note: The options object will also be passed as the last argument to every event handler.

This object may contain any of the following properties:

scope :  Object

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

delay :  Number

The number of milliseconds to delay the invocation of the handler after the event fires.

single :  Boolean

True to add a handler to handle just the next firing of the event, and then remove itself.

buffer :  Number

Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

onFrame :  Number

Causes the handler to be scheduled to run at the next animation frame event. If the event fires again before that time, the handler is not rescheduled - the handler will only be called once when the next animation frame is fired, with the last set of arguments passed.

target :  Ext.util.Observable

Only call the handler if the event was fired on the target Observable, not if the event was bubbled up from a child Observable.

element :  String

This option is only valid for listeners bound to Ext.Component. The name of a Component property which references an Ext.dom.Element to add a listener to.

This option is useful during Component construction to add DOM event listeners to elements of Ext.Component which will exist only after the Component is rendered.

For example, to add a click listener to a Panel's body:

  var panel = new Ext.panel.Panel({
      title: 'The title',
      listeners: {
          click: this.handlePanelClick,
          element: 'body'
      }
  });

In order to remove listeners attached using the element, you'll need to reference the element itself as seen below.

 panel.body.un(...)

delegate :  String (optional)

A simple selector to filter the event target or look for a descendant of the target.

The "delegate" option is only available on Ext.dom.Element instances (or when attaching a listener to a Ext.dom.Element via a Component using the element option).

See the delegate example below.

capture :  Boolean (optional)

When set to true, the listener is fired in the capture phase of the event propagation sequence, instead of the default bubble phase.

The capture option is only available on Ext.dom.Element instances (or when attaching a listener to a Ext.dom.Element via a Component using the element option).

stopPropagation :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call stopPropagation on the event object before firing the handler.

preventDefault :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call preventDefault on the event object before firing the handler.

stopEvent :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call stopEvent on the event object before firing the handler.

args :  Array (optional)

Optional set of arguments to pass to the handler function before the actual fired event arguments. For example, if args is set to ['foo', 42], the event handler function will be called with an arguments list like this:

 handler('foo', 42, <actual event arguments>...);

destroyable :  Boolean (optional)

When specified as true, the function returns a destroyable object. An object which implements the destroy method which removes all listeners added in this call. This syntax can be a helpful shortcut to using un; particularly when removing multiple listeners. NOTE - not compatible when using the element option. See un for the proper syntax for removing listeners added using the element config.

Defaults to:

false

priority :  Number (optional)

An optional numeric priority that determines the order in which event handlers are run. Event handlers with no priority will be run as if they had a priority of 0. Handlers with a higher priority will be prioritized to run sooner than those with a lower priority. Negative numbers can be used to set a priority lower than the default. Internally, the framework uses a range of 1000 or greater, and -1000 or lesser for handlers that are intended to run before or after all others, so it is recommended to stay within the range of -999 to 999 when setting the priority of event handlers in application-level code. A priority must be an integer to be valid. Fractional values are reserved for internal framework use.

order :  String (optional)

A legacy option that is provided for backward compatibility. It is recommended to use the priority option instead. Available options are:

  • 'before': equal to a priority of 100
  • 'current': equal to a priority of 0 or default priority
  • 'after': equal to a priority of -100

Defaults to:

'current'

order :  String (optional)

A shortcut for the order event option. Provided for backward compatibility. Please use the priority event option instead.

Defaults to: 'current'

Returns

:Object

Only when the destroyable option is specified.

A Destroyable object. An object which implements the destroy method which removes all listeners added in this call. For example:

this.btnListeners =  = myButton.on({
    destroyable: true
    mouseover:   function() { console.log('mouseover'); },
    mouseout:    function() { console.log('mouseout'); },
    click:       function() { console.log('click'); }
});

And when those listeners need to be removed:

Ext.destroy(this.btnListeners);

or

this.btnListeners.destroy();

addManagedListener ( item, ename, [fn], [scope], [options] ) : Object

The addManagedListener method is used when some object (call it "A") is listening to an event on another observable object ("B") and you want to remove that listener from "B" when "A" is destroyed. This is not an issue when "B" is destroyed because all of its listeners will be removed at that time.

Example:

Ext.define('Foo', {
    extend: 'Ext.Component',

    initComponent: function () {
        this.addManagedListener(MyApp.SomeSharedMenu, 'show', this.doSomething);
        this.callParent();
    }
});

As you can see, when an instance of Foo is destroyed, it ensures that the 'show' listener on the menu (MyApp.SomeGlobalSharedMenu) is also removed.

As of version 5.1 it is no longer necessary to use this method in most cases because listeners are automatically managed if the scope object provided to addListener is an Observable instance. However, if the observable instance and scope are not the same object you still need to use mon or addManagedListener if you want the listener to be managed.

Parameters

item :  Ext.util.Observable/Ext.dom.Element

The item to which to add a listener/listeners.

ename :  Object/String

The event name, or an object containing event name properties.

fn :  Function/String (optional)

If the ename parameter was an event name, this is the handler function or the name of a method on the specified scope.

scope :  Object (optional)

If the ename parameter was an event name, this is the scope (this reference) in which the handler function is executed.

options :  Object (optional)

If the ename parameter was an event name, this is the addListener options.

Returns

:Object

Only when the destroyable option is specified.

A Destroyable object. An object which implements the destroy method which removes all listeners added in this call. For example:

this.btnListeners = myButton.mon({
    destroyable: true
    mouseover:   function() { console.log('mouseover'); },
    mouseout:    function() { console.log('mouseout'); },
    click:       function() { console.log('click'); }
});

And when those listeners need to be removed:

Ext.destroy(this.btnListeners);

or

this.btnListeners.destroy();

clear

Removes all items from the collection. Fires the event-clear event when complete.

Available since: 1.1.0

clearListeners

Removes all listeners for this object including the managed listeners

clearManagedListeners

Removes all managed listeners for this object.

clone Ext.util.MixedCollection

Creates a shallow copy of this collection

Available since: 1.1.0

Returns

:Ext.util.MixedCollection

collect ( property, [root], [allowNull] ) : Array

Collects unique values of a particular property in this MixedCollection

Parameters

property :  String

The property to collect on

root :  String (optional)

'root' property to extract the first argument from. This is used mainly when summing fields in records, where the fields are all stored inside the 'data' object

allowNull :  Boolean (optional)

Pass true to allow null, undefined or empty string values

Returns

:Array

The unique values

constructor ( config )

Creates new MixedCollection.

Parameters

config :  Object

A configuration object.

allowFunctions :  Boolean (optional)

Specify true if the addAll function should add function references to the collection.

Defaults to:

false

getKey :  Function (optional)

A function that can accept an item of the type(s) stored in this MixedCollection and return the key value for that item. This is used when available to look up the key on items that were passed without an explicit key parameter to a MixedCollection method. Passing this parameter is equivalent to overriding the method-getKey method.

contains ( o ) : Boolean

Returns true if the collection contains the passed Object as an item.

Available since: 1.1.0

Parameters

o :  Object

The Object to look for in the collection.

Returns

:Boolean

True if the collection contains the Object as an item.

containsKey ( key ) : Boolean

Returns true if the collection contains the passed Object as a key.

Available since: 1.1.0

Parameters

key :  String

The key to look for in the collection.

Returns

:Boolean

True if the collection contains the Object as a key.

createRelayer ( newName, [beginEnd] ) : Function
private pri

Creates an event handling function which re-fires the event from this object as the passed event name.

Parameters

newName :  String

The name under which to re-fire the passed parameters.

beginEnd :  Array (optional)

The caller can specify on which indices to slice.

Returns

:Function

createValueMatcher ( value, anyMatch, caseSensitive, exactMatch )
private pri

Returns a regular expression based on the given value and matching options. This is used internally for finding and filtering, and by Ext.data.Store#filter

Available since: 3.4.0

Parameters

value :  String

The value to create the regex for. This is escaped using Ext.escapeRe

anyMatch :  Boolean

True to allow any match - no regex start/end line anchors will be added. Defaults to false

caseSensitive :  Boolean

True to make the regex case sensitive (adds 'i' switch to regex). Defaults to false.

exactMatch :  Boolean

True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.

decodeSorters ( sorters ) : Ext.util.Sorter[]
private pri

Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances

Parameters

sorters :  Object[]

The sorters array

Returns

:Ext.util.Sorter[]

Array of Ext.util.Sorter objects

destroy
private pri

Destructor for classes that extend Observable.

doFireEvent ( eventName, args, bubbles )
private pri

Continue to fire event.

Parameters

eventName :  String

args :  Array

bubbles :  Boolean

each ( fn, [scope] )

Executes the specified function once for every item in the collection. The function should return a boolean value. Returning false from the function will stop the iteration.

Available since: 1.1.0

Parameters

fn :  Function

The function to execute for each item.

item :  Mixed

The collection item.

index :  Number

The index of item.

len :  Number

Total length of collection.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to the current item in the iteration.

eachKey ( fn, [scope] )

Executes the specified function once for every key in the collection, passing each key, and its associated item as the first two parameters.

Available since: 1.1.0

Parameters

fn :  Function

The function to execute for each item.

key :  String

The key of collection item.

item :  Mixed

The collection item.

index :  Number

The index of item.

len :  Number

Total length of collection.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to the browser window.

enableBubble ( eventNames )

Enables events fired by this Observable to bubble up an owner hierarchy by calling this.getBubbleTarget() if present. There is no implementation in the Observable base class.

This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component#getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly.

Example:

Ext.define('Ext.overrides.form.field.Base', {
    override: 'Ext.form.field.Base',

    //  Add functionality to Field's initComponent to enable
    // the change event to bubble
    initComponent: function () {
        this.callParent();
        this.enableBubble('change');
    }
});

var myForm = Ext.create('Ext.form.Panel', {
    title: 'User Details',
    items: [{
        ...
    }],
    listeners: {
        change: function() {
            // Title goes red if form has been modified.
            myForm.header.setStyle('color', 'red');
        }
    }
});

Parameters

eventNames :  String/String[]

The event name to bubble, or an Array of event names.

extractValues ( property, [root] ) : Array
private pri

Extracts all of the given property values from the items in the MC. Mainly used as a supporting method for functions like sum and collect.

Parameters

property :  String

The property to extract

root :  String (optional)

'root' property to extract the first argument from. This is used mainly when extracting field data from Model instances, where the fields are stored inside the 'data' object

Returns

:Array

The extracted values

filter ( property, value, [anyMatch], [caseSensitive] ) : Ext.util.MixedCollection

Filters the objects in this collection by a set of Ext.util.Filters, or by a single property/value pair with optional parameters for substring matching and case sensitivity. See Ext.util.Filter for an example of using Filter objects (preferred). Alternatively, MixedCollection can be easily filtered by property like this:

// create a simple store with a few people defined
var people = new Ext.util.MixedCollection();
people.addAll([
    {id: 1, age: 25, name: 'Ed'},
    {id: 2, age: 24, name: 'Tommy'},
    {id: 3, age: 24, name: 'Arne'},
    {id: 4, age: 26, name: 'Aaron'}
]);

// a new MixedCollection containing only the items where age == 24
var middleAged = people.filter('age', 24);

Available since: 1.1.0

Parameters

property :  Ext.util.Filter[]/String

A property on your objects, or an array of Ext.util.Filter objects

value :  String/RegExp

Either string that the property values should start with or a RegExp to test against the property

anyMatch :  Boolean (optional)

True to match any part of the string, not just the beginning

Defaults to: false

caseSensitive :  Boolean (optional)

True for case sensitive comparison.

Defaults to: false

Returns

:Ext.util.MixedCollection

The new filtered collection

filterBy ( fn, [scope] ) : Ext.util.MixedCollection

Filter by a function. Returns a new collection that has been filtered. The passed function will be called with each object in the collection. If the function returns true, the value is included otherwise it is filtered.

Available since: 1.1.0

Parameters

fn :  Function

The function to be called.

item :  Mixed

The collection item.

key :  String

The key of collection item.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to this MixedCollection.

Returns

:Ext.util.MixedCollection

The new filtered collection

find
deprecated dep

Returns the first item in the collection which elicits a true return value from the passed selection function.

Available since: 1.1.0

Deprecated since version 4.0
Use findBy instead.

findBy ( fn, [scope] ) : Object

Returns the first item in the collection which elicits a true return value from the passed selection function.

Parameters

fn :  Function

The selection function to execute for each item.

item :  Mixed

The collection item.

key :  String

The key of collection item.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to the browser window.

Returns

:Object

The first item in the collection which returned true from the selection function, or null if none was found.

findIndex ( property, value, [start], [anyMatch], [caseSensitive] ) : Number

Finds the index of the first matching object in this collection by a specific property/value.

Available since: 2.3.0

Parameters

property :  String

The name of a property on your objects.

value :  String/RegExp

A string that the property values should start with or a RegExp to test against the property.

start :  Number (optional)

The index to start searching at.

Defaults to: 0

anyMatch :  Boolean (optional)

True to match any part of the string, not just the beginning.

Defaults to: false

caseSensitive :  Boolean (optional)

True for case sensitive comparison.

Defaults to: false

Returns

:Number

The matched index or -1

findIndexBy ( fn, [scope], [start] ) : Number

Find the index of the first matching object in this collection by a function. If the function returns true it is considered a match.

Available since: 2.3.0

Parameters

fn :  Function

The function to be called.

item :  Mixed

The collection item.

key :  String

The key of collection item.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to this MixedCollection.

start :  Number (optional)

The index to start searching at.

Defaults to: 0

Returns

:Number

The matched index or -1

findInsertionIndex ( newItem, [sorterFn] ) : Number

Calculates the insertion index of the new item based upon the comparison function passed, or the current sort order.

Parameters

newItem :  Object

The new object to find the insertion position of.

sorterFn :  Function (optional)

The function to sort by. This is the same as the sorting function passed to sortBy. It accepts 2 items from this MixedCollection, and returns -1 0, or 1 depending on the relative sort positions of the 2 compared items.

If omitted, a function generated from the currently defined set of cfg-sorters will be used.

Returns

:Number

The insertion point to add the new item into this MixedCollection at using insert

fireAction ( eventName, args, fn, [scope], [options], [order] )
deprecated dep

Fires the specified event with the passed parameters and executes a function (action). By default, the action function will be executed after any "before" event handlers (as specified using the order option of addListener), but before any other handlers are fired. This gives the "before" handlers an opportunity to cancel the event by returning false, and prevent the action function from being called.

The action can also be configured to run after normal handlers, but before any "after" handlers (as specified using the order event option) by passing 'after' as the order parameter. This configuration gives any event handlers except for "after" handlers the opportunity to cancel the event and prevent the action function from being called.

Parameters

eventName :  String

The name of the event to fire.

args :  Array

Arguments to pass to handlers and to the action function.

fn :  Function

The action function.

scope :  Object (optional)

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

options :  Object (optional)

Event options for the action function. Accepts any of the options of addListener

order :  String (optional)

The order to call the action function relative too the event handlers ('before' or 'after'). Note that this option is simply used to sort the action function relative to the event handlers by "priority". An order of 'before' is equivalent to a priority of 99.5, while an order of 'after' is equivalent to a priority of -99.5. See the priority option of addListener for more details.

Defaults to: 'before'

Deprecated since version 5.5
Use fireEventedAction instead.

fireEvent ( eventName, args ) : Boolean

Fires the specified event with the passed parameters (minus the event name, plus the options object passed to addListener).

An event may be set to bubble up an Observable parent hierarchy (See Ext.Component#getBubbleTarget) by calling enableBubble.

Parameters

eventName :  String

The name of the event to fire.

args :  Object...

Variable number of parameters are passed to handlers.

Returns

:Boolean

returns false if any of the handlers return false otherwise it returns true.

fireEventArgs ( eventName, args ) : Boolean

Fires the specified event with the passed parameter list.

An event may be set to bubble up an Observable parent hierarchy (See Ext.Component#getBubbleTarget) by calling enableBubble.

Parameters

eventName :  String

The name of the event to fire.

args :  Object[]

An array of parameters which are passed to handlers.

Returns

:Boolean

returns false if any of the handlers return false otherwise it returns true.

fireEventedAction ( eventName, args, fn, [scope], [fnArgs] ) : Boolean

Fires the specified event with the passed parameters and executes a function (action). Evented Actions will automatically dispatch a 'before' event passing. This event will be given a special controller that allows for pausing/resuming of the event flow.

By pausing the controller the updater and events will not run until resumed. Pausing, however, will not stop the processing of any other before events.

Parameters

eventName :  String

The name of the event to fire.

args :  Array

Arguments to pass to handlers and to the action function.

fn :  Function/String

The action function.

scope :  Object (optional)

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

fnArgs :  Array/Boolean (optional)

Optional arguments for the action fn. If not given, the normal args will be used to call fn. If false is passed, the args are used but if the first argument is this instance it will be removed from the args passed to the action function.

Returns

:Boolean

first Object

Returns the first item in the collection.

Available since: 1.1.0

Returns

:Object

the first item in the collection..

generateComparator

Returns a comparator function which compares two items and returns -1, 0, or 1 depending on the currently defined set of cfg-sorters.

If there are no cfg-sorters defined, it returns a function which returns 0 meaning that no sorting will occur.

get ( key ) : Object

Returns the item associated with the passed key OR index. Key has priority over index. This is the equivalent of calling getByKey first, then if nothing matched calling getAt.

Available since: 1.1.0

Parameters

key :  String/Number

The key or index of the item.

Returns

:Object

If the item is found, returns the item. If the item was not found, returns undefined. If an item was found, but is a Class, returns null.

getAt ( index ) : Object

Returns the item at the specified index.

Parameters

index :  Number

The index of the item.

Returns

:Object

The item at the specified index.

getBubbleParent Ext.util.Observable
private pri

Gets the bubbling parent for an Observable

Returns

:Ext.util.Observable

The bubble parent. null is returned if no bubble target exists

getByField ( fieldName ) : Object[]

Returns all of the errors for the given field

Parameters

fieldName :  String

The field to get errors for

Returns

:Object[]

All errors for the given field

getByKey ( key ) : Object

Returns the item associated with the passed key.

Parameters

key :  String/Number

The key of the item.

Returns

:Object

The item associated with the passed key.

getCount Number

Returns the number of items in the collection.

Available since: 1.1.0

Returns

:Number

the number of items in the collection.

getFirstSorter Ext.util.Sorter
protected pro

Gets the first sorter from the sorters collection, excluding any groupers that may be in place

Returns

:Ext.util.Sorter

The sorter, null if none exist

getId String

Retrieves the id. This method Will auto-generate an id if one has not already been configured.

Returns

:String

id

getKey ( item ) : Object
template tpl

A function which will be called, passing a newly added object when the object is added without a separate id. The function should yield the key by which that object will be indexed.

If no key is yielded, then the object will be added, but it cannot be accessed or removed quickly. Finding it in this collection for interrogation or removal will require a linear scan of this collection's items.

The default implementation simply returns item.id but you can provide your own implementation to return a different value as in the following examples:

// normal way
var mc = new Ext.util.MixedCollection();
mc.add(someEl.dom.id, someEl);
mc.add(otherEl.dom.id, otherEl);
//and so on

// using getKey
var mc = new Ext.util.MixedCollection({
    getKey: function(el){
        return el.dom.id;
    }
});
mc.add(someEl);
mc.add(otherEl);

Available since: 1.1.0

Parameters

item :  Object

The item for which to find the key.

Returns

:Object

The key for the passed item.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

getRange ( [start], [end] ) : Array

Returns a range of items in this collection

Available since: 1.1.0

Parameters

start :  Number (optional)

The starting index. Defaults to 0.

end :  Number (optional)

The ending index. Defaults to the last item.

Returns

:Array

An array of items

getSorterCount
protected pro

Returns the number of Sorters which apply to this Sortable.

May be overridden in subclasses. Ext.data.Store in particlar overrides this because its groupers must contribute to the sorter count so that the sort method above executes doSort.

hasListener ( eventName ) : Boolean

Checks to see if this object has any listeners for a specified event, or whether the event bubbles. The answer indicates whether the event needs firing or not.

Parameters

eventName :  String

The name of the event to check for

Returns

:Boolean

true if the event is being listened for or bubbles, else false

hasRange ( start, end )
private pri

For API parity with Store's PageMap class. Buffered rendering checks if the Store has the range required to render. The Store delegates this question to its backing data object which may be an instance of its private PageMap class, or a MixedCollection.

Parameters

start :  Object

end :  Object

indexOf ( o ) : Number

Returns index within the collection of the passed Object.

Available since: 1.1.0

Parameters

o :  Object

The item to find the index of.

Returns

:Number

index of the item. Returns -1 if not found.

indexOfKey ( key ) : Number

Returns index within the collection of the passed key.

Available since: 1.1.0

Parameters

key :  String

The key to find the index of.

Returns

:Number

index of the key.

insert ( index, key, [obj] ) : Object

Inserts an item at the specified index in the collection. Fires the event-add event when complete.

Available since: 1.1.0

Parameters

index :  Number

The index to insert the item at.

key :  String/Object/String[]/Object[]

The key to associate with the new item, or the item itself. May also be an array of either to insert multiple items at once.

obj :  Object/Object[] (optional)

If the second parameter was a key, the new item. May also be an array to insert multiple items at once.

Returns

:Object

The item inserted or an array of items inserted.

isSuspended ( [event] ) : Boolean

Checks if all events, or a specific event, is suspended.

Parameters

event :  String (optional)

The name of the specific event to check

Returns

:Boolean

true if events are suspended

isValid Boolean

Returns true if there are no errors in the collection

Returns

:Boolean

last Object

Returns the last item in the collection.

Available since: 1.1.0

Returns

:Object

the last item in the collection..

mon ( item, ename, [fn], [scope], [options] ) : Object

Shorthand for addManagedListener. The addManagedListener method is used when some object (call it "A") is listening to an event on another observable object ("B") and you want to remove that listener from "B" when "A" is destroyed. This is not an issue when "B" is destroyed because all of its listeners will be removed at that time.

Example:

Ext.define('Foo', {
    extend: 'Ext.Component',

    initComponent: function () {
        this.addManagedListener(MyApp.SomeGlobalSharedMenu, 'show', this.doSomething);
        this.callParent();
    }
});

As you can see, when an instance of Foo is destroyed, it ensures that the 'show' listener on the menu (MyApp.SomeGlobalSharedMenu) is also removed.

As of version 5.1 it is no longer necessary to use this method in most cases because listeners are automatically managed if the scope object provided to addListener is an Observable instance. However, if the observable instance and scope are not the same object you still need to use mon or addManagedListener if you want the listener to be managed.

Parameters

item :  Ext.util.Observable/Ext.dom.Element

The item to which to add a listener/listeners.

ename :  Object/String

The event name, or an object containing event name properties.

fn :  Function/String (optional)

If the ename parameter was an event name, this is the handler function or the name of a method on the specified scope.

scope :  Object (optional)

If the ename parameter was an event name, this is the scope (this reference) in which the handler function is executed.

options :  Object (optional)

If the ename parameter was an event name, this is the addListener options.

Returns

:Object

Only when the destroyable option is specified.

A Destroyable object. An object which implements the destroy method which removes all listeners added in this call. For example:

this.btnListeners = myButton.mon({
    destroyable: true
     mouseover:   function() { console.log('mouseover'); },
    mouseout:    function() { console.log('mouseout'); },
    click:       function() { console.log('click'); }
});

And when those listeners need to be removed:

Ext.destroy(this.btnListeners);

or

this.btnListeners.destroy();

mun ( item, ename, [fn], [scope] )

Shorthand for removeManagedListener. Removes listeners that were added by the mon method.

Parameters

item :  Ext.util.Observable/Ext.dom.Element

The item from which to remove a listener/listeners.

ename :  Object/String

The event name, or an object containing event name properties.

fn :  Function (optional)

If the ename parameter was an event name, this is the handler function.

scope :  Object (optional)

If the ename parameter was an event name, this is the scope (this reference) in which the handler function is executed.

on ( eventName, [fn], [scope], [options], [order] ) : Object

The on method is shorthand for addListener.

Appends an event handler to this object. For example:

myGridPanel.on("itemclick", this.onItemClick, this);

The method also allows for a single argument to be passed which is a config object containing properties which specify multiple events. For example:

myGridPanel.on({
    cellclick: this.onCellClick,
    select: this.onSelect,
    viewready: this.onViewReady,
    scope: this // Important. Ensure "this" is correct during handler execution
});

One can also specify options for each event handler separately:

myGridPanel.on({
    cellclick: {fn: this.onCellClick, scope: this, single: true},
    viewready: {fn: panel.onViewReady, scope: panel}
});

Names of methods in a specified scope may also be used:

myGridPanel.on({
    cellclick: {fn: 'onCellClick', scope: this, single: true},
    viewready: {fn: 'onViewReady', scope: panel}
});

Parameters

eventName :  String/Object

The name of the event to listen for. May also be an object who's property names are event names.

fn :  Function/String (optional)

The method the event invokes or the name of the method within the specified scope. Will be called with arguments given to Ext.util.Observable#fireEvent plus the options parameter described below.

scope :  Object (optional)

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

options :  Object (optional)

An object containing handler configuration.

Note: The options object will also be passed as the last argument to every event handler.

This object may contain any of the following properties:

scope :  Object

The scope (this reference) in which the handler function is executed. If omitted, defaults to the object which fired the event.

delay :  Number

The number of milliseconds to delay the invocation of the handler after the event fires.

single :  Boolean

True to add a handler to handle just the next firing of the event, and then remove itself.

buffer :  Number

Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

onFrame :  Number

Causes the handler to be scheduled to run at the next animation frame event. If the event fires again before that time, the handler is not rescheduled - the handler will only be called once when the next animation frame is fired, with the last set of arguments passed.

target :  Ext.util.Observable

Only call the handler if the event was fired on the target Observable, not if the event was bubbled up from a child Observable.

element :  String

This option is only valid for listeners bound to Ext.Component. The name of a Component property which references an Ext.dom.Element to add a listener to.

This option is useful during Component construction to add DOM event listeners to elements of Ext.Component which will exist only after the Component is rendered.

For example, to add a click listener to a Panel's body:

  var panel = new Ext.panel.Panel({
      title: 'The title',
      listeners: {
          click: this.handlePanelClick,
          element: 'body'
      }
  });

In order to remove listeners attached using the element, you'll need to reference the element itself as seen below.

 panel.body.un(...)

delegate :  String (optional)

A simple selector to filter the event target or look for a descendant of the target.

The "delegate" option is only available on Ext.dom.Element instances (or when attaching a listener to a Ext.dom.Element via a Component using the element option).

See the delegate example below.

capture :  Boolean (optional)

When set to true, the listener is fired in the capture phase of the event propagation sequence, instead of the default bubble phase.

The capture option is only available on Ext.dom.Element instances (or when attaching a listener to a Ext.dom.Element via a Component using the element option).

stopPropagation :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call stopPropagation on the event object before firing the handler.

preventDefault :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call preventDefault on the event object before firing the handler.

stopEvent :  Boolean (optional)

This option is only valid for listeners bound to Ext.dom.Element. true to call stopEvent on the event object before firing the handler.

args :  Array (optional)

Optional arguments to pass to the handler function. Any additional arguments passed to fireEvent will be appended to these arguments.

destroyable :  Boolean (optional)

When specified as true, the function returns a destroyable object. An object which implements the destroy method which removes all listeners added in this call. This syntax can be a helpful shortcut to using un; particularly when removing multiple listeners. NOTE - not compatible when using the element option. See un for the proper syntax for removing listeners added using the element config.

Defaults to:

false

priority :  Number (optional)

An optional numeric priority that determines the order in which event handlers are run. Event handlers with no priority will be run as if they had a priority of 0. Handlers with a higher priority will be prioritized to run sooner than those with a lower priority. Negative numbers can be used to set a priority lower than the default. Internally, the framework uses a range of 1000 or greater, and -1000 or lesser for handlers that are intended to run before or after all others, so it is recommended to stay within the range of -999 to 999 when setting the priority of event handlers in application-level code. A priority must be an integer to be valid. Fractional values are reserved for internal framework use.

order :  String (optional)

A legacy option that is provided for backward compatibility. It is recommended to use the priority option instead. Available options are:

  • 'before': equal to a priority of 100
  • 'current': equal to a priority of 0 or default priority
  • 'after': equal to a priority of -100

Defaults to:

'current'

order :  String (optional)

A shortcut for the order event option. Provided for backward compatibility. Please use the priority event option instead.

Combining Options

Using the options argument, it is possible to combine different types of listeners:

A delayed, one-time listener.

myPanel.on('hide', this.handleClick, this, {
    single: true,
    delay: 100
});

Attaching multiple handlers in 1 call

The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers and handler configs.

grid.on({
    itemclick: 'onItemClick',
    itemcontextmenu: grid.onItemContextmenu,
    destroy: {
        fn: function () {
            // function called within the 'altCmp' scope instead of grid
        },
        scope: altCmp // unique scope for the destroy handler
    },
    scope: grid       // default scope - provided for example clarity
});

Delegate

This is a configuration option that you can pass along when registering a handler for an event to assist with event delegation. By setting this configuration option to a simple selector, the target element will be filtered to look for a descendant of the target. For example:

var panel = Ext.create({
    xtype: 'panel',
    renderTo: document.body,
    title: 'Delegate Handler Example',
    frame: true,
    height: 220,
    width: 220,
    html: '<h1 class="myTitle">BODY TITLE</h1>Body content'
});

// The click handler will only be called when the click occurs on the
// delegate: h1.myTitle ("h1" tag with class "myTitle")
panel.on({
    click: function (e) {
        console.log(e.getTarget().innerHTML);
    },
    element: 'body',
    delegate: 'h1.myTitle'
 });

Defaults to: 'current'

Returns

:Object

Only when the destroyable option is specified.

A Destroyable object. An object which implements the destroy method which removes all listeners added in this call. For example:

this.btnListeners =  = myButton.on({
    destroyable: true
    mouseover:   function() { console.log('mouseover'); },
    mouseout:    function() { console.log('mouseout'); },
    click:       function() { console.log('click'); }
});

And when those listeners need to be removed:

Ext.destroy(this.btnListeners);

or

this.btnListeners.destroy();

onAfter ( eventName, fn, [scope], [options] )

Appends an after-event handler.

Same as addListener with order set to 'after'.

Parameters

eventName :  String/String[]/Object

The name of the event to listen for.

fn :  Function/String

The method the event invokes.

scope :  Object (optional)

The scope for fn.

options :  Object (optional)

An object containing handler configuration.

onBefore ( eventName, fn, [scope], [options] )

Appends a before-event handler. Returning false from the handler will stop the event.

Same as addListener with order set to 'before'.

Parameters

eventName :  String/String[]/Object

The name of the event to listen for.

fn :  Function/String

The method the event invokes.

scope :  Object (optional)

The scope for fn.

options :  Object (optional)

An object containing handler configuration.

relayEvents ( origin, events, [prefix] ) : Object

Relays selected events from the specified Observable as if the events were fired by this.

For example if you are extending Grid, you might decide to forward some events from store. So you can do this inside your initComponent:

this.relayEvents(this.getStore(), ['load']);

The grid instance will then have an observable 'load' event which will be passed the parameters of the store's load event and any function fired with the grid's load event would have access to the grid using the this keyword (unless the event is handled by a controller's control/listen event listener in which case 'this' will be the controller rather than the grid).

Parameters

origin :  Object

The Observable whose events this object is to relay.

events :  String[]/Object

Array of event names to relay or an Object with key/value pairs translating to ActualEventName/NewEventName respectively. For example: this.relayEvents(this, {add:'push', remove:'pop'});

Would now redispatch the add event of this as a push event and the remove event as a pop event.

prefix :  String (optional)

A common prefix to prepend to the event names. For example:

this.relayEvents(this.getStore(), ['load', 'clear'], 'store');

Now the grid will forward 'load' and 'clear' events of store as 'storeload' and 'storeclear'.

Returns

:Object

A Destroyable object. An object which implements the destroy method which, when destroyed, removes all relayers. For example:

this.storeRelayers = this.relayEvents(this.getStore(), ['load', 'clear'], 'store');

Can be undone by calling

Ext.destroy(this.storeRelayers);

or this.store.relayers.destroy();

remove ( o ) : Object

Remove an item from the collection.

Available since: 1.1.0

Parameters

o :  Object

The item to remove.

Returns

:Object

The item removed or false if no item was removed.

removeAll ( [items] ) : Ext.util.MixedCollection

Remove all items in the collection. Can also be used to remove only the items in the passed array.

Parameters

items :  Array (optional)

An array of items to be removed.

Returns

:Ext.util.MixedCollection

this object

removeAt ( index ) : Object

Remove an item from a specified index in the collection. Fires the event-remove event when complete.

Available since: 1.1.0

Parameters

index :  Number

The index within the collection of the item to remove.

Returns

:Object

The item removed or false if no item was removed.

removeAtKey ( key ) : Object

Removes an item associated with the passed key fom the collection.

Parameters

key :  String

The key of the item to remove. If null is passed, all objects which yielded no key from the configured getKey function are removed.

Returns

:Object

Only returned if removing at a specified key. The item removed or false if no item was removed.

removeListener ( eventName, fn, [scope] ) :
chainable ch

Removes an event handler.

Parameters

eventName :  String

The type of event the handler was associated with.

fn :  Function

The handler to remove. This must be a reference to the function passed into the addListener call.

scope :  Object (optional)

The scope originally specified for the handler. It must be the same as the scope argument specified in the original call to Ext.util.Observable#addListener or the listener will not be removed.

Returns

:

removeManagedListener ( item, ename, [fn], [scope] )

Removes listeners that were added by the mon method.

Parameters

item :  Ext.util.Observable/Ext.dom.Element

The item from which to remove a listener/listeners.

ename :  Object/String

The event name, or an object containing event name properties.

fn :  Function (optional)

If the ename parameter was an event name, this is the handler function.

scope :  Object (optional)

If the ename parameter was an event name, this is the scope (this reference) in which the handler function is executed.

removeManagedListenerItem ( isClear, managedListener, item, ename, fn, scope )
private pri

Remove a single managed listener item

Parameters

isClear :  Boolean

True if this is being called during a clear

managedListener :  Object

The managed listener item

item :  Object

ename :  String

fn :  Function

scope :  Object

See removeManagedListener for other args

removeRange ( index, [removeCount] ) : Object

Remove a range of items starting at a specified index in the collection. Does not fire the remove event.

Parameters

index :  Number

The index within the collection of the item to remove.

removeCount :  Number (optional)

The nuber of items to remove beginning at the specified index.

Defaults to: 1

Returns

:Object

The last item removed or false if no item was removed.

reorder ( mapping )

Reorders each of the items based on a mapping from old index to new index. Internally this just translates into a sort. The 'sort' event is fired whenever reordering has occurred.

Parameters

mapping :  Object

Mapping from old item index to new item index

// example of moving the last of 4 items to the front of the collection
// and moving each one before it forward one
collection.reorder({
    0: 1,
    1: 2,
    2: 3,
    3: 0,
});

replace ( key, o ) : Object

Replaces an item in the collection. Fires the event-replace event when complete.

Available since: 1.1.0

Parameters

key :  String

The key associated with the item to replace, or the replacement item.

If you supplied a getKey implementation for this MixedCollection, or if the key of your stored items is in a property called id, then the MixedCollection will be able to derive the key of the replacement item. If you want to replace an item with one having the same key value, then just pass the replacement item in this parameter.

o :  Object

o (optional) If the first parameter passed was a key, the item to associate with that key.

Returns

:Object

The new item.

resolveListenerScope ( [defaultScope] ) : Object
protected pro

Gets the default scope for firing late bound events (string names with no scope attached) at runtime.

Parameters

defaultScope :  Object (optional)

The default scope to return if none is found.

Defaults to: this

Returns

:Object

The default event scope

resumeEvent ( eventName )

Resumes firing of the named event(s).

After calling this method to resume events, the events will fire when requested to fire.

Note that if the suspendEvent method is called multiple times for a certain event, this converse method will have to be called the same number of times for it to resume firing.

Parameters

eventName :  String...

Multiple event names to resume.

resumeEvents ( [discardQueue] )

Resumes firing events (see suspendEvents).

If events were suspended using the queueSuspended parameter, then all events fired during event suspension will be sent to any listeners now.

Parameters

discardQueue :  Boolean (optional)

true to prevent any previously queued events from firing while we were suspended. See suspendEvents.

sort ( [sorters], [direction], [insertionPosition], doSort ) : Ext.util.Sorter[]

Updates the sorters collection and triggers sorting of this Sortable. Example usage:

//sort by a single field
myStore.sort('myField', 'DESC');

//sorting by multiple fields
myStore.sort([{
    property : 'age',
    direction: 'ASC'
}, {
    property : 'name',
    direction: 'DESC'
}]);

Classes which use this mixin must implement a soSort method which accepts a comparator function computed from the full sorter set which performs the sort in an implementation-specific way.

When passing a single string argument to sort, Store maintains a ASC/DESC toggler per field, so this code:

store.sort('myField');
store.sort('myField');

Is equivalent to this code, because Store handles the toggling automatically:

store.sort('myField', 'ASC');
store.sort('myField', 'DESC');

Parameters

sorters :  String/Ext.util.Sorter[] (optional)

Either a string name of one of the fields in this Store's configured Ext.data.Model, or an array of sorter configurations.

direction :  String (optional)

The overall direction to sort the data by.

Defaults to: "ASC"

insertionPosition :  String (optional)

Where to put the new sorter in the collection of sorters. This may take the following values:

  • replace: This means that the new sorter(s) becomes the sole sorter set for this Sortable. This is the most useful call mode to programatically sort by multiple fields.

  • prepend: This means that the new sorters are inserted as the primary sorters, unchanged, and the sorter list length must be controlled by the developer.

  • multi: This is mainly useful for implementing intuitive "Sort by this" user interfaces such as the GridPanel's column sorting UI. This mode is only supported when passing a property name and a direction. This means that the new sorter becomes the primary sorter. If the sorter was already the primary sorter, the direction of sort is toggled if no direction parameter is specified. The number of sorters maintained is limited by the multiSortLimit configuration.

  • append : This means that the new sorter becomes the last sorter.

Defaults to: "replace"

doSort :  Boolean

True to sort using a generated sorter function that combines all of the Sorters passed

Returns

:Ext.util.Sorter[]

The new sorters.

sortBy ( sorterFn )

Sorts the collection by a single sorter function

Parameters

sorterFn :  Function

The function to sort by

sortByKey ( [dir], [fn] )

Sorts this collection by keys.

Parameters

dir :  "ASC"/"DESC" (optional)

'ASC' or 'DESC'. Defaults to 'ASC'.

Defaults to: "ASC"

fn :  Function (optional)

Comparison function that defines the sort order. Defaults to sorting by case insensitive string.

sum ( property, [root], [start], [end] ) : Number

Collects all of the values of the given property and returns their sum

Parameters

property :  String

The property to sum by

root :  String (optional)

'root' property to extract the first argument from. This is used mainly when summing fields in records, where the fields are all stored inside the 'data' object

start :  Number (optional)

The record index to start at

Defaults to: 0

end :  Number (optional)

The record index to end at

Defaults to: -1

Returns

:Number

The total

suspendEvent ( eventName )

Suspends firing of the named event(s).

After calling this method to suspend events, the events will no longer fire when requested to fire.

Note that if this is called multiple times for a certain event, the converse method resumeEvent will have to be called the same number of times for it to resume firing.

Parameters

eventName :  String...

Multiple event names to suspend.

suspendEvents ( queueSuspended )

Suspends the firing of all events. (see resumeEvents)

Parameters

queueSuspended :  Boolean

true to queue up suspended events to be fired after the resumeEvents call instead of discarding all suspended events.

un ( eventName, fn, [scope] )

Shorthand for removeListener. Removes an event handler.

Parameters

eventName :  String

The type of event the handler was associated with.

fn :  Function

The handler to remove. This must be a reference to the function passed into the addListener call.

scope :  Object (optional)

The scope originally specified for the handler. It must be the same as the scope argument specified in the original call to Ext.util.Observable#addListener or the listener will not be removed.

Convenience Syntax

You can use the addListener destroyable: true config option in place of calling un(). For example:

var listeners = cmp.on({
    scope: cmp,
    afterrender: cmp.onAfterrender,
    beforehide: cmp.onBeforeHide,
    destroyable: true
});

// Remove listeners
listeners.destroy();
// or
cmp.un(
    scope: cmp,
    afterrender: cmp.onAfterrender,
    beforehide: cmp.onBeforeHide
);

Exception - DOM event handlers using the element config option

You must go directly through the element to detach an event handler attached using the addListener element option.

panel.on({
    element: 'body',
    click: 'onBodyCLick'
});

panel.body.un({
    click: 'onBodyCLick'
});

unAfter ( eventName, fn, [scope], [options] )

Removes a before-event handler.

Same as removeListener with order set to 'after'.

Parameters

eventName :  String/String[]/Object

The name of the event the handler was associated with.

fn :  Function/String

The handler to remove.

scope :  Object (optional)

The scope originally specified for fn.

options :  Object (optional)

Extra options object.

unBefore ( eventName, fn, [scope], [options] )

Removes a before-event handler.

Same as removeListener with order set to 'before'.

Parameters

eventName :  String/String[]/Object

The name of the event the handler was associated with.

fn :  Function/String

The handler to remove.

scope :  Object (optional)

The scope originally specified for fn.

options :  Object (optional)

Extra options object.

updateKey ( oldKey, newKey )

Change the key for an existing item in the collection. If the old key does not exist this is a no-op.

Parameters

oldKey :  Object

The old key

newKey :  Object

The new key

Static Methods

override ( members ) : Ext.Base
static sta

Override members of this class. Overridden methods can be invoked via Ext.Base#callParent.

Ext.define('My.Cat', {
    constructor: function() {
        alert("I'm a cat!");
    }
});

My.Cat.override({
    constructor: function() {
        alert("I'm going to be a cat!");

        this.callParent(arguments);

        alert("Meeeeoooowwww");
    }
});

var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
                          // alerts "I'm a cat!"
                          // alerts "Meeeeoooowwww"

Direct use of this method should be rare. Use Ext.define instead:

Ext.define('My.CatOverride', {
    override: 'My.Cat',
    constructor: function() {
        alert("I'm going to be a cat!");

        this.callParent(arguments);

        alert("Meeeeoooowwww");
    }
});

The above accomplishes the same result but can be managed by the Ext.Loader which can properly order the override and its target class and the build process can determine whether the override is needed based on the required state of the target class (My.Cat).

Parameters

members :  Object

The properties to add to this class. This should be specified as an object literal containing one or more properties.

Returns

:Ext.Base

this class

events

add ( index, o, key, eOpts )

Fires when an item is added to the collection.

Available since: 1.1.0

Parameters

index :  Number

The index at which the item was added.

o :  Object

The item added.

key :  String

The key associated with the added item.

eOpts : Object

The options object passed to Ext.util.Observable.addListener.

beforesort ( me, sorters, eOpts )

Fires before a sort occurs.

Parameters

me :  Ext.util.Sortable

This object.

sorters :  Ext.util.Sorter[]

The collection of Sorters being used to generate the comparator function.

eOpts : Object

The options object passed to Ext.util.Observable.addListener.

clear

Fires when the collection is cleared.

Available since: 1.1.0

remove ( o, key, eOpts )

Fires when an item is removed from the collection.

Available since: 1.1.0

Parameters

o :  Object

The item being removed.

key :  String

The key associated with the removed item.

eOpts : Object

The options object passed to Ext.util.Observable.addListener.

replace ( key, old, new, eOpts )

Fires when an item is replaced in the collection.

Available since: 1.1.0

Parameters

key :  String

he key associated with the new added.

old :  Object

The item being replaced.

new :  Object

The new item.

eOpts : Object

The options object passed to Ext.util.Observable.addListener.

ExtReact 6.7.0