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.

ExtAngular 7.5.0


top

Ext.Array singleton

NPM Package

@sencha/ext-core

Hierarchy

Ext.Array

Summary

A set of useful static methods to deal with arrays; provide missing methods for older browsers.

No members found using the current filters

properties

methods

Instance Methods

binarySearch ( array, item, [begin], [end], [compareFn] ) : Number

This method returns the index that a given item would be inserted into the given (sorted) array. Note that the given item may or may not be in the array. This method will return the index of where the item should be.

For example:

 var array = [ 'A', 'D', 'G', 'K', 'O', 'R', 'X' ];
 var index = Ext.Array.binarySearch(array, 'E');

 console.log('index: ' + index);
 // logs "index: 2"

 array.splice(index, 0, 'E');

 console.log('array : ' + array.join(''));
 // logs "array: ADEGKORX"

Parameters

array :  Object[]

The array to search.

item :  Object

The item that you want to insert into the array.

begin :  Number (optional)

The first index in the array to consider.

Defaults to: 0

end :  Number (optional)

The index that marks the end of the range to consider. The item at this index is not considered.

Defaults to: array.length

compareFn :  Function (optional)

The comparison function that matches the sort order of the array. The default compareFn compares items using less-than and greater-than operators.

Returns

:Number

The index for the given item in the given array based on the current sorters.

clean ( array ) : Array

Filter through an array and remove empty item as defined in Ext.isEmpty.

See Ext.Array#filter

Parameters

array :  Array

Returns

:Array

results

clone ( array ) : Array

Clone a flat array without referencing the previous one. Note that this is different from Ext.clone since it doesn't handle recursive cloning. It's simply a convenient, easy-to-remember method for Array.prototype.slice.call(array).

Parameters

array :  Array

The array.

Returns

:Array

The clone array.

contains ( array, item ) : Boolean

Checks whether or not the given array contains the specified item.

Parameters

array :  Array

The array to check.

item :  Object

The item to find.

Returns

:Boolean

true if the array contains the item, false otherwise.

difference ( arrayA, arrayB ) : Array

Perform a set difference A-B by subtracting all items in array B from array A.

Parameters

arrayA :  Array

arrayB :  Array

Returns

:Array

difference

each ( array, fn, [scope], [reverse] ) : Boolean/Number

Iterates an array or an iterable value and invoke the given callback function for each item.

var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];

Ext.Array.each(countries, function(name, index, countriesItSelf) {
    console.log(name);
});

var sum = function() {
    var sum = 0;

    Ext.Array.each(arguments, function(value) {
        sum += value;
    });

    return sum;
};

sum(1, 2, 3); // returns 6

The iteration can be stopped by returning false from the callback function. Returning undefined (i.e return;) will only exit the callback function and proceed with the next iteration of the loop.

Ext.Array.each(countries, function(name, index, countriesItSelf) {
    if (name === 'Singapore') {
        return false; // break here
    }
});

Ext.each is alias for Ext.Array.each

Parameters

array :  Array/NodeList/Object

The value to be iterated. If this argument is not iterable, the callback function is called once.

fn :  Function

The callback function. If it returns false, the iteration stops and this method returns the current index. Returning undefined (i.e return;) will only exit the callback function and proceed with the next iteration in the loop.

item :  Object

The item at the current index in the passed array

index :  Number

The current index within the array

allItems :  Array

The array itself which was passed as the first argument

return :  Boolean

Return false to stop iteration.

scope :  Object (optional)

The scope (this reference) in which the specified function is executed.

reverse :  Boolean (optional)

Reverse the iteration order (loop from the end to the beginning).

Defaults to: false

Returns

:Boolean/Number

If all array entries were iterated, this will be true. If iteration was halted early because the passed fuction returnedfalse`, this will be the index at which iteration was halted.

equals ( array1, array2 ) : Boolean

Shallow compares the contents of 2 arrays using strict equality.

Parameters

array1 :  Array

array2 :  Array

Returns

:Boolean

true if the arrays are equal.

erase ( array, index, removeCount ) : Array

Removes items from an array. This is functionally equivalent to the splice method of Array, but works around bugs in IE8's splice method and does not copy the removed elements in order to return them (because very often they are ignored).

Parameters

array :  Array

The Array on which to replace.

index :  Number

The index in the array at which to operate.

removeCount :  Number

The number of items to remove at index.

Returns

:Array

The array passed.

every ( array, fn, scope ) : Boolean

Executes the specified function for each array element until the function returns a falsy value. If such an item is found, the function will return false immediately. Otherwise, it will return true.

Parameters

array :  Array

fn :  Function

Callback function for each item.

item :  Mixed

Current item.

index :  Number

Index of the item.

array :  Array

The whole array that's being iterated.

scope :  Object

Callback function scope.

Returns

:Boolean

true if no false value is returned by the callback function.

filter ( array, fn, scope ) : Array

Creates a new array with all of the elements of this array for which the provided filtering function returns a truthy value.

Parameters

array :  Array

fn :  Function

Callback function for each item.

item :  Mixed

Current item.

index :  Number

Index of the item.

array :  Array

The whole array that's being iterated.

scope :  Object

Callback function scope.

Returns

:Array

results

findBy ( array, fn, [scope] ) : Object

Returns the first item in the array which elicits a truthy return value from the passed selection function.

Parameters

array :  Array

The array to search

fn :  Function

The selection function to execute for each item.

item :  Mixed

The array item.

index :  Number

The index of the array item.

scope :  Object (optional)

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

Returns

:Object

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

flatten ( array ) : Array

Recursively flattens into 1-d Array. Injects Arrays inline.

Parameters

array :  Array

The array to flatten

Returns

:Array

The 1-d array.

forEach ( array, fn, scope )

Iterates an array and invoke the given callback function for each item. Note that this will simply delegate to the native Array.prototype.forEach method if supported. It doesn't support stopping the iteration by returning false in the callback function like Ext.Array#each. However, performance could be much better in modern browsers comparing with Ext.Array#each

Parameters

array :  Array

The array to iterate.

fn :  Function

The callback function.

item :  Object

The item at the current index in the passed array.

index :  Number

The current index within the array.

allItems :  Array

The array itself which was passed as the first argument.

scope :  Object

The execution scope (this) in which the specified function is executed.

from ( value, [newReference] ) : Array

Converts a value to an array if it's not already an array; returns:

  • An empty array if given value is undefined or null
  • Itself if given value is already an array
  • An array copy if given value is iterable (arguments, NodeList and alike)
  • An array with one item which is the given value, otherwise

Parameters

value :  Object

The value to convert to an array if it's not already is an array.

newReference :  Boolean (optional)

true to clone the given array and return a new reference if necessary.

Returns

:Array

array

include ( array, item )

Push an item into the array only if the array doesn't contain it yet.

Parameters

array :  Array

The array.

item :  Object

The item to include.

indexOf ( array, item, from ) : Number

Get the index of the provided item in the given array, a supplement for the missing arrayPrototype.indexOf in Internet Explorer.

Parameters

array :  Array

The array to check.

item :  Object

The item to find.

from :  Number

The index at which to begin the search.

Returns

:Number

The index of item in the array (or -1 if it is not found).

insert ( array, index, items ) : Array

Inserts items in to an array.

Parameters

array :  Array

The Array in which to insert.

index :  Number

The index in the array at which to operate.

items :  Array

The array of items to insert at index.

Returns

:Array

The array passed.

intersect ( array1, array2, etc ) : Array

Merge multiple arrays into one with unique items that exist in all of the arrays.

Parameters

array1 :  Array

array2 :  Array

etc :  Array

Returns

:Array

intersect

map ( array, fn, [scope] ) : Array

Creates a new array with the results of calling a provided function on every element in this array.

Parameters

array :  Array

fn :  Function

Callback function for each item.

item :  Mixed

Current item.

index :  Number

Index of the item.

array :  Array

The whole array that's being iterated.

scope :  Object (optional)

Callback function scope

Returns

:Array

results

max ( array, [comparisonFn] ) : Object

Returns the maximum value in the Array.

Parameters

array :  Array/NodeList

The Array from which to select the maximum value.

comparisonFn :  Function (optional)

a function to perform the comparison which determines maximization. If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1

max :  Mixed

Current maximum value.

item :  Mixed

The value to compare with the current maximum.

Returns

:Object

maxValue The maximum value.

mean ( array ) : Number

Calculates the mean of all items in the array.

Parameters

array :  Array

The Array to calculate the mean value of.

Returns

:Number

The mean.

merge ( array1, array2, etc ) : Array

Merge multiple arrays into one with unique items.

Ext.Array#union is alias for Ext.Array#merge

Parameters

array1 :  Array

array2 :  Array

etc :  Array

Returns

:Array

merged

min ( array, [comparisonFn] ) : Object

Returns the minimum value in the Array.

Parameters

array :  Array/NodeList

The Array from which to select the minimum value.

comparisonFn :  Function (optional)

a function to perform the comparison which determines minimization. If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1

min :  Mixed

Current minimum value.

item :  Mixed

The value to compare with the current minimum.

Returns

:Object

minValue The minimum value.

numericSortFn ( a, b )

A function used to sort an array by numeric value. By default, javascript array values are coerced to strings when sorting, which can be problematic when using numeric values. To ensure that the values are sorted numerically, this method can be passed to the sort method:

Ext.Array.sort(myArray, Ext.Array.numericSortFn);

Parameters

a :  Object

b :  Object

pluck ( array, propertyName ) : Array

Plucks the value of a property from each item in the Array. Example:

// [el1.className, el2.className, ..., elN.className]
Ext.Array.pluck(Ext.query("p"), "className");

Parameters

array :  Array/NodeList

The Array of items to pluck the value from.

propertyName :  String

The property name to pluck from each element.

Returns

:Array

The value from each item in the Array.

push ( target, elements ) : Array

Pushes new items onto the end of an Array.

Passed parameters may be single items, or arrays of items. If an Array is found in the argument list, all its elements are pushed into the end of the target Array.

Parameters

target :  Array

The Array onto which to push new items

elements :  Object...

The elements to add to the array. Each parameter may be an Array, in which case all the elements of that Array will be pushed into the end of the destination Array.

Returns

:Array

An array containing all the new items push onto the end.

reduce ( array, reduceFn, [initialValue] ) : Mixed

This method applies the reduceFn function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.

If no initialValue is specified, the first element of the array is used as the initial value. For example:

 function reducer (previous, value, index) {
     console.log('[' + index + ']: (' + previous + ',' + value + '}');
     return previous * 10 + value;
 }

 v = Ext.Array.reduce([2, 3, 4], reducer);
 console.log('v = ' + v);

 > [1]: (2, 3)
 > [2]: (23, 4)
 > v = 234

 v = Ext.Array.reduce([2, 3, 4], reducer, 1);
 console.log('v = ' + v);

 > [0]: (1, 2)
 > [1]: (12, 3)
 > [2]: (123, 4)
 > v = 1234

Available since: 6.0.0

Parameters

array :  Array

The array to process.

reduceFn :  Function

The reducing callback function.

previous :  Mixed

The previous value.

value :  Mixed

The current value.

index :  Number

The index in the array of the current value.

array :  Array

The array to being processed.

initialValue :  Mixed (optional)

The starting value.

Returns

:Mixed

The reduced value.

remove ( array, item ) : Array

Removes the specified item from the array if it exists.

Parameters

array :  Array

The array.

item :  Object

The item to remove.

Returns

:Array

The passed array.

removeAt ( array, index, [count] ) : Array

Removes item/s at the specified index.

Parameters

array :  Array

The array.

index :  Number

The index of the item to be removed.

count :  Number (optional)

The number of items to be removed.

Defaults to: 1

Returns

:Array

The passed array.

replace ( array, index, removeCount, [insert] ) : Array

Replaces items in an array. This is functionally equivalent to the splice method of Array, but works around bugs in IE8's splice method and is often more convenient to call because it accepts an array of items to insert rather than use a variadic argument list.

Parameters

array :  Array

The Array on which to replace.

index :  Number

The index in the array at which to operate.

removeCount :  Number

The number of items to remove at index (can be 0).

insert :  Array (optional)

An array of items to insert at index.

Returns

:Array

The array passed.

slice ( array, begin, end ) : Array

Returns a shallow copy of a part of an array. This is equivalent to the native call Array.prototype.slice.call(array, begin, end). This is often used when "array" is "arguments" since the arguments object does not supply a slice method but can be the context object to Array.prototype.slice.

Parameters

array :  Array

The array (or arguments object).

begin :  Number

The index at which to begin. Negative values are offsets from the end of the array.

end :  Number

The index at which to end. The copied items do not include end. Negative values are offsets from the end of the array. If end is omitted, all items up to the end of the array are copied.

Returns

:Array

The copied piece of the array.

some ( array, fn, scope ) : Boolean

Executes the specified function for each array element until the function returns a truthy value. If such an item is found, the function will return true immediately. Otherwise, it will return false.

Parameters

array :  Array

fn :  Function

Callback function for each item.

item :  Mixed

Current item.

index :  Number

Index of the item.

array :  Array

The whole array that's being iterated.

scope :  Object

Callback function scope.

Returns

:Boolean

true if the callback function returns a truthy value.

sort ( array, [sortFn] ) : Array

Sorts the elements of an Array in a stable manner (equivalently keyed values do not move relative to each other). By default, this method sorts the elements alphabetically and ascending. Note: This method modifies the passed array, in the same manner as the native javascript Array.sort.

Parameters

array :  Array

The array to sort.

sortFn :  Function (optional)

The comparison function.

a :  Mixed

The first item to compare.

b :  Mixed

The second item to compare.

return :  Number

-1 if a < b, 1 if a > b, otherwise 0.

Returns

:Array

The sorted array.

splice ( array, index, removeCount, elements ) : Array

Replaces items in an array. This is equivalent to the splice method of Array, but works around bugs in IE8's splice method. The signature is exactly the same as the splice method except that the array is the first argument. All arguments following removeCount are inserted in the array at index.

Parameters

array :  Array

The Array on which to replace.

index :  Number

The index in the array at which to operate.

removeCount :  Number

The number of items to remove at index (can be 0).

elements :  Object...

The elements to add to the array. If you don't specify any elements, splice simply removes elements from the array.

Returns

:Array

An array containing the removed items.

sum ( array ) : Number

Calculates the sum of all items in the given array.

Parameters

array :  Array

The Array to calculate the sum value of.

Returns

:Number

The sum.

toArray ( iterable, [start], [end] ) : Array

Converts any iterable (numeric indices and a length property) into a true array.

function test() {
    var args = Ext.Array.toArray(arguments),
        fromSecondToLastArgs = Ext.Array.toArray(arguments, 1);

    alert(args.join(' '));
    alert(fromSecondToLastArgs.join(' '));
}

test('just', 'testing', 'here'); // alerts 'just testing here';
                                 // alerts 'testing here';

// will convert the NodeList into an array
Ext.Array.toArray(document.getElementsByTagName('div'));
Ext.Array.toArray('splitted'); // returns ['s', 'p', 'l', 'i', 't', 't', 'e', 'd']
Ext.Array.toArray('splitted', 0, 3); // returns ['s', 'p', 'l']

Ext.toArray is alias for Ext.Array.toArray

Parameters

iterable :  Object

the iterable object to be turned into a true Array.

start :  Number (optional)

a zero-based index that specifies the start of extraction.

Defaults to: 0

end :  Number (optional)

a 1-based index that specifies the end of extraction.

Defaults to: -1

Returns

:Array

toMap ( strings, [getKey], [scope] ) : Object

Creates a map (object) keyed by the elements of the given array. The values in the map are the index+1 of the array element. For example:

 var map = Ext.Array.toMap(['a','b','c']);

 // map = { a: 1, b: 2, c: 3 };

Or a key property can be specified:

 var map = Ext.Array.toMap([
         { name: 'a' },
         { name: 'b' },
         { name: 'c' }
     ], 'name');

 // map = { a: 1, b: 2, c: 3 };

Lastly, a key extractor can be provided:

 var map = Ext.Array.toMap([
         { name: 'a' },
         { name: 'b' },
         { name: 'c' }
     ], function(obj) { return obj.name.toUpperCase(); });

 // map = { A: 1, B: 2, C: 3 };

Parameters

strings :  String/String[]

The strings from which to create the map.

getKey :  String/Function (optional)

Name of the object property to use as a key or a function to extract the key.

scope :  Object (optional)

Value of this inside callback specified for getKey.

Returns

:Object

The resulting map.

toValueMap ( array, [getKey], [scope], [arrayify] ) : Object

Creates a map (object) keyed by a property of elements of the given array. The values in the map are the array element. For example:

 var map = Ext.Array.toValueMap(['a','b','c']);

 // map = { a: 'a', b: 'b', c: 'c' };

Or a key property can be specified:

 var map = Ext.Array.toValueMap([
         { name: 'a' },
         { name: 'b' },
         { name: 'c' }
     ], 'name');

 // map = { a: {name: 'a'}, b: {name: 'b'}, c: {name: 'c'} };

Lastly, a key extractor can be provided:

 var map = Ext.Array.toValueMap([
         { name: 'a' },
         { name: 'b' },
         { name: 'c' }
     ], function(obj) { return obj.name.toUpperCase(); });

 // map = { A: {name: 'a'}, B: {name: 'b'}, C: {name: 'c'} };

Parameters

array :  Array

The Array to create the map from.

getKey :  String/Function (optional)

Name of the object property to use as a key or a function to extract the key.

scope :  Object (optional)

Value of this inside callback. This parameter is only passed when getKey is a function. If getKey is not a function, the 3rd argument is arrayify.

arrayify :  Number (optional)

Pass 1 to create arrays for all map entries or 2 to create arrays for map entries that have 2 or more items with the same key. This only applies when getKey is specified. By default the map will hold the last entry with a given key.

Returns

:Object

The resulting map.

union ( array1, array2, etc ) : Array

Merge multiple arrays into one with unique items.

Ext.Array#union is alias for Ext.Array#merge

Parameters

array1 :  Array

array2 :  Array

etc :  Array

Returns

:Array

merged

unique ( array ) : Array

Returns a new array with unique items.

Parameters

array :  Array

Returns

:Array

results

ExtAngular 7.5.0