Ext.grid.property.Store
Alternate names
Ext.grid.PropertyStoreHierarchy
Ext.BaseExt.data.AbstractStoreExt.data.StoreExt.grid.property.StoreInherited mixins
Uses
Files
A custom Ext.data.Store for the Ext.grid.property.Grid. This class handles the mapping between the custom data source objects supported by the grid and the Ext.grid.property.Property format used by the Ext.data.Store base class.
Available since: 1.1.0
Config options
If data is not specified, and if autoLoad is true or an Object, this store's load method is automatically called after creation. If the value of autoLoad is an Object, this Object will be passed to the store's load method.
Defaults to: false
Available since: Ext 2
True to automatically sync the Store with its Proxy after every edit to one of its Records. Defaults to false.
Defaults to: false
Available since: 4.0.0
Allow the store to buffer and pre-fetch pages of records. This is to be used in conjunction with a view will tell the store to pre-fetch records ahead of a time.
Defaults to: false
Available since: 4.0.0
True to empty the store when loading another page via loadPage, nextPage or previousPage. Setting to false keeps existing records, allowing large data sets to be loaded one page at a time but rendered all together.
Defaults to: true
Available since: 4.0.0
Optional array of Model instances or data objects to load locally. See "Inline data" above for details.
Available since: 1.1.0
This may be used in place of specifying a model configuration. The fields should be a set of Ext.data.Field configuration objects. The store will automatically create a Ext.data.Model with these fields. In general this configuration option should be avoided, it exists for the purposes of backwards compatibility. For anything more complicated, such as specifying a particular id property or assocations, a Ext.data.Model should be defined and specified for the model config.
Available since: Ext 2
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 Components
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'); }
}
}
});
Available since: 1.1.0
Name of the Model associated with this store. The string is used as an argument for Ext.ModelManager.getModel.
Available since: 4.0.4
The number of records considered to form a 'page'. This is used to power the built-in paging using the nextPage and previousPage functions. Defaults to 25.
Defaults to: 25
Available since: 4.0.1
The Proxy to use for this Store. This can be either a string, a config object or a Proxy instance - see setProxy for details.
Available since: 1.1.0
Overrides: Ext.data.AbstractStore.proxy
The number of pages to keep in the cache before purging additional records. A value of 0 indicates to never purge the prefetched data. This option is only relevant when the buffered option is set to true.
Defaults to: 5
Available since: 4.0.0
True to defer any filtering operation to the server. If false, filtering is done locally on the client. Defaults to false.
Defaults to: false
Available since: 4.0.0
True if the grouping should apply on the server side, false if it is local only. If the grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a helper, automatically sending the grouping information to the server.
Defaults to: false
Available since: 4.0.0
True to defer any sorting operation to the server. If false, sorting is done locally on the client. Defaults to false.
Defaults to: false
Available since: 1.1.0
Unique identifier for this store. If present, this Store will be registered with the Ext.data.StoreManager, making it easy to reuse elsewhere. Defaults to undefined.
Available since: 4.0.0
Properties
Sets the updating behavior based on batch synchronization. 'operation' (the default) will update the Store's internal representation of the data after each operation of the batch has completed, 'complete' will wait until the entire batch has been completed before updating the Store's data. 'complete' is a good choice for local storage proxies, 'operation' is better for remote proxies, where there is a comparatively high latency.
Defaults to: 'operation'
Available since: 4.0.0
The page that the Store has most recently loaded (see loadPage)
Defaults to: 1
Available since: 4.0.0
The MixedCollection that holds this store's local cache of records
The MixedCollection that holds this store's local cache of records
Available since: 4.0.0
The string type of the Proxy to create if none is specified. This defaults to creating a memory proxy.
Defaults to: 'memory'
Available since: 4.0.0
The default sort direction to use if one is not specified.
Defaults to: "ASC"
Available since: 4.0.0
Defaults to: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|vertical|horizontal|freezeEvent)$/
Available since: 4.0.0
If true, any filters attached to this Store will be run after loading data, before the datachanged event is fired. Defaults to true, ignored if remoteFilter is true
Defaults to: true
Available since: 4.0.0
The direction in which sorting should be applied when grouping. Defaults to "ASC" - the other supported value is "DESC"
Defaults to: "ASC"
Available since: 4.0.0
True if a model was created implicitly for this Store. This happens if a fields array is passed to the Store's constructor instead of a model constructor or name.
Defaults to: false
Available since: 4.0.0
True if the Store has already been destroyed. If this is true, the reference to Store should be deleted as it will not function correctly any more.
Defaults to: false
Available since: Ext 3
Flag denoting that this object is sortable. Always true.
Defaults to: true
Available since: 4.0.0
True if the Store is currently loading via its Proxy
Defaults to: false
Available since: 4.0.0
A set of default values to be applied to every model instance added via insert or created via create. This is used internally by associations to set foreign keys and other fields. See the Association classes source code for examples. This should not need to be used by application developers.
Available since: 4.0.0
Temporary cache in which removed model instances are kept until successfully synchronised with a Proxy, at which point this is cleared.
Available since: 4.0.0
Get the reference to the current class from which this object was instantiated. Unlike statics,
this.self is scope-dependent and it's meant to be used for dynamic inheritance. See statics
for a detailed comparison
Ext.define('My.Cat', {
statics: {
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
alert(this.self.speciesName); / dependent on 'this'
return this;
},
clone: function() {
return new this.self();
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
}
});
var cat = new My.Cat(); // alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
Available since: 4.0.0
A pristine (unfiltered) collection of the records in this store. This is used to reinstate records when a filter is removed or changed
Available since: 4.0.0
If true, any sorters attached to this Store will be run after loading data, before the datachanged event is fired. Defaults to true, igored if remoteSort is true
Defaults to: true
Available since: 4.0.0
The property in each item that contains the data to sort.
The property in each item that contains the data to sort.
Available since: 4.0.0
Methods
Instance Methods Creates new property store. ...Creates new property store.
Available since: 1.1.0
Parameters
- grid : Ext.grid.Panel
The grid this store will be bound to
- source : Object
The source data config object
Returns
Overrides: Ext.data.Store.constructor
Adds Model instance to the Store. ...Adds Model instance to the Store. This method accepts either:
- An array of Model instances or Model configuration objects.
- Any number of Model instance or Model configuration object arguments.
The new Model instances will be added at the end of the existing collection.
Sample usage:
myStore.add({some: 'data'}, {some: 'other data'});
Available since: 1.1.0
Parameters
- model : Ext.data.Model[]/Ext.data.Model...
An array of Model instances
or Model configuration objects, or variable number of Model instance or config arguments.
Returns
- Ext.data.Model[]
The model instances that were added
addEvents( o, [more] )Adds the specified events to the list of events which this Observable may fire. ...Adds the specified events to the list of events which this Observable may fire.
Available since: 1.1.0
Parameters
- o : Object/String
Either an object with event names as properties with a value of true or the first
event name string if multiple event names are being passed as separate parameters. Usage:
this.addEvents({
storeloaded: true,
storecleared: true
});
- more : String... (optional)
Additional event names if multiple event names are being passed as separate
parameters. Usage:
this.addEvents('storeloaded', 'storecleared');
addListener( eventName, fn, [scope], [options] )Appends an event handler to this object. ...Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for. May also be an object who's property names are
event names.
- fn : Function
The method the event invokes. Will be called with arguments given to
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: Unlike in ExtJS 3.x, 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.
target : 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 Components. The name of a Component
property which references an element to add a listener to.
This option is useful during Component construction to add DOM event listeners to elements of
Components which will exist only after the Component is rendered.
For example, to add a click listener to a Panel's body:
new Ext.panel.Panel({
title: 'The title',
listeners: {
click: this.handlePanelClick,
element: 'body'
}
});
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 events. For example:
myGridPanel.on({
cellClick: this.onCellClick,
mouseover: this.onMouseOver,
mouseout: this.onMouseOut,
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},
mouseover: {fn: panel.onMouseOver, scope: panel}
});
addManagedListener( item, ename, [fn], [scope], [opt] )Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is
destr...Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is
destroyed.
Available since: 4.0.0
Parameters
- item : Ext.util.Observable/Ext.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 (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.
- opt : Object (optional)
If the ename parameter was an event name, this is the
addListener options.
afterCommit( record )privateA model instance should call this method on the Store it has been joined to. ...A model instance should call this method on the Store it has been joined to.
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
afterEdit( record )privateA model instance should call this method on the Store it has been joined to. ...A model instance should call this method on the Store it has been joined to.
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
afterReject( record )privateA model instance should call this method on the Store it has been joined to.. ...A model instance should call this method on the Store it has been joined to..
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
Runs the aggregate function for all the records in the store. ...Runs the aggregate function for all the records in the store.
Available since: 4.0.0
Parameters
- fn : Function
The function to execute. The function is called with a single parameter,
an array of records for that group.
- scope : Object (optional)
The scope to execute the function in. Defaults to the store.
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the group average being the value. The grouped parameter is only honored if
the store has a groupField.
- args : Array (optional)
Any arguments to append to the function call
Returns
- Object
An object literal with the group names and their appropriate values.
Gets the average value in the store. ...Gets the average value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the group average being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Object
The average value, if no items exist, 0.
cacheRecords( records, The )privateCaches the records in the prefetch and stripes them with their server-side
index. ...Caches the records in the prefetch and stripes them with their server-side
index.
Available since: 4.0.0
Parameters
- records : Ext.data.Model[]
The records to cache
- The : Ext.data.Operation
associated operation
Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: functi...Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. ...Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
from the current method, for example: this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
clearFilter( suppressEvent )Revert to a view of the Record cache with no filtering applied. ...Revert to a view of the Record cache with no filtering applied.
Available since: 1.1.0
Parameters
- suppressEvent : Boolean
If true the filter is cleared silently without firing the
datachanged event.
Overrides: Ext.data.AbstractStore.clearFilter
Removes all listeners for this object including the managed listeners ...Removes all listeners for this object including the managed listeners
Available since: 4.0.0
Removes all managed listeners for this object. ...Removes all managed listeners for this object.
Available since: 4.0.0
Collects unique values for a particular dataIndex from this store. ...Collects unique values for a particular dataIndex from this store.
Available since: 1.1.0
Parameters
- dataIndex : String
The property to collect
- allowNull : Boolean (optional)
Pass true to allow null, undefined or empty string values
- bypassFilter : Boolean (optional)
Pass true to collect from all records, even ones which are filtered
Returns
- Object[]
An array of the unique values
continueFireEvent( eventName, args, bubbles )★private Gets the count of items in the store. ...Gets the count of items in the store.
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the count for each group being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Number
the count
create( data, options )private createFilterFn( property, value, [anyMatch], [caseSensitive], [exactMatch] )privateReturns a filter function used to test a the given property's value. ...Returns a filter function used to test a the given property's value. Defers most of the work to
Ext.util.MixedCollection's createValueMatcher function
Available since: 3.4.0
Parameters
- property : String
The property to create the filter function for
- value : String/RegExp
The string/regex to compare the property value to
- anyMatch : Boolean (optional)
True if we don't care if the filter value is not the full value.
Defaults to: false
- caseSensitive : Boolean (optional)
True to create a case-sensitive regex.
Defaults to: false
- exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex).
Ignored if anyMatch is true.
Defaults to: false
Converts a literal to a model, if it's not a model already ...Converts a literal to a model, if it's not a model already
Available since: 4.0.0
Parameters
- record : Object
{Ext.data.Model/Object} The record to create
Returns
Normalizes an array of filter objects, ensuring that they are all Ext.util.Filter instances ...Normalizes an array of filter objects, ensuring that they are all Ext.util.Filter instances
Available since: 4.0.0
Parameters
- filters : Object[]
The filters array
Returns
- Ext.util.Filter[]
Array of Ext.util.Filter objects
Normalizes an array of grouper objects, ensuring that they are all Ext.util.Grouper instances ...Normalizes an array of grouper objects, ensuring that they are all Ext.util.Grouper instances
Available since: 4.0.0
Parameters
- groupers : Object[]
The groupers array
Returns
- Ext.util.Grouper[]
Array of Ext.util.Grouper objects
Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances ...Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances
Available since: 4.0.0
Parameters
- sorters : Object[]
The sorters array
Returns
- Ext.util.Sorter[]
Array of Ext.util.Sorter objects
destroy( options )privatetells the attached proxy to destroy the given records ...tells the attached proxy to destroy the given records
Available since: Ext 3
Parameters
- options : Object
doSort( sorterFn )privateoverriden to provide striping of the indexes as sorting occurs. ...overriden to provide striping of the indexes as sorting occurs.
this cannot be done inside of sort because datachanged has already
fired and will trigger a repaint of the bound view.
Available since: 4.0.0
Parameters
- sorterFn : Object
Overrides: Ext.data.AbstractStore.doSort
each( fn, [scope] )Calls the specified function for each of the Records in the cache. ...Calls the specified function for each of the Records in the cache.
Available since: 1.1.0
Parameters
enableBubble( events )Enables events fired by this Observable to bubble up an owner hierarchy by calling this.getBubbleTarget() if
present. ...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.override(Ext.form.field.Base, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.Function.createSequence(Ext.form.field.Base.prototype.initComponent, function() {
this.enableBubble('change');
}),
// We know that we want Field's events to bubble directly to the FormPanel.
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
// Title goes red if form has been modified.
myForm.header.setStyle('color', 'red');
}
}
});
Available since: 3.4.0
Parameters
filter( filters, [value] )Filters the loaded set of records by a given set of filters. ...Filters the loaded set of records by a given set of filters.
Filtering by single field:
store.filter("email", /\.com$/);
Using multiple filters:
store.filter([
{property: "email", value: /\.com$/},
{filterFn: function(item) { return item.get("age") > 10; }}
]);
Using Ext.util.Filter instances instead of config objects
(note that we need to specify the root config option in this case):
store.filter([
Ext.create('Ext.util.Filter', {property: "email", value: /\.com$/, root: 'data'}),
Ext.create('Ext.util.Filter', {filterFn: function(item) { return item.get("age") > 10; }, root: 'data'})
]);
Available since: 1.1.0
Parameters
- filters : Object[]/Ext.util.Filter[]/String
The set of filters to apply to the data. These are stored internally on the store,
but the filtering itself is done on the Store's MixedCollection. See
MixedCollection's filter method for filter syntax. Alternatively,
pass in a property string
- value : String (optional)
value to filter by (only if using a property string as the first argument)
Overrides: Ext.data.AbstractStore.filter
filterBy( fn, [scope] )Filter by a function. ...Filter by a function. The specified function will be called for each
Record in this Store. If the function returns true the Record is included,
otherwise it is filtered out.
Available since: 1.1.0
Parameters
- fn : Function
The function to be called. It will be passed the following parameters:
- record : Ext.data.Model
The record
to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- scope : Object (optional)
The scope (this reference) in which the function is executed. Defaults to this Store.
Overrides: Ext.data.AbstractStore.filterBy
Finds the index of the first matching Record in this store by a specific field value. ...Finds the index of the first matching Record in this store by a specific field value.
Available since: 2.3.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : String/RegExp
Either a string that the field value
should begin with, or a RegExp to test against the field.
- startIndex : Number (optional)
The index to start searching at
- anyMatch : Boolean (optional)
True to match any part of the string, not just the beginning
- caseSensitive : Boolean (optional)
True for case sensitive comparison
- exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex). Defaults to false.
Returns
- Number
The matched index or -1
Find the index of the first matching Record in this Store by a function. ...Find the index of the first matching Record in this Store 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. It will be passed the following parameters:
- record : Ext.data.Model
The record
to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- scope : Object (optional)
The scope (this reference) in which the function is executed. Defaults to this Store.
- startIndex : Number (optional)
The index to start searching at
Returns
- Number
The matched index or -1
Finds the index of the first matching Record in this store by a specific field value. ...Finds the index of the first matching Record in this store by a specific field value.
Available since: 3.4.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : Object
The value to match the field against.
- startIndex : Number (optional)
The index to start searching at
Returns
- Number
The matched index or -1
findRecord( fieldName, value, [startIndex], [anyMatch], [caseSensitive], [exactMatch] ) : Ext.data.ModelFinds the first matching Record in this store by a specific field value. ...Finds the first matching Record in this store by a specific field value.
Available since: 4.0.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : String/RegExp
Either a string that the field value
should begin with, or a RegExp to test against the field.
- startIndex : Number (optional)
The index to start searching at
- anyMatch : Boolean (optional)
True to match any part of the string, not just the beginning
- caseSensitive : Boolean (optional)
True for case sensitive comparison
- exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex). Defaults to false.
Returns
- Ext.data.Model
The matched record or null
Fires the specified event with the passed parameters (minus the event name, plus the options object passed
to addList...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.
Available since: 1.1.0
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.
fireGroupChange( )privateFires the groupchange event. ...Fires the groupchange event. Abstracted out so we can use it
as a callback
Available since: 4.0.0
Convenience function for getting the first model instance in the store ...Convenience function for getting the first model instance in the store
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the first record being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Ext.data.Model/undefined
The first model instance in the store, or undefined
Get the Record at the specified index. ...Get the Record at the specified index.
Available since: 1.1.0
Parameters
- index : Number
The index of the Record to find.
Returns
- Ext.data.Model
The Record at the passed index. Returns undefined if not found.
getAverage( records, field )private getBatchListeners( ) : ObjectprivateReturns an object which is passed in as the listeners argument to proxy.batch inside this.sync. ...Returns an object which is passed in as the listeners argument to proxy.batch inside this.sync.
This is broken out into a separate function to allow for customisation of the listeners
Available since: 4.0.0
Returns
- Object
The listeners object
getBubbleParent( ) : Ext.util.Observable★privateGets the bubbling parent for an Observable ...Gets the bubbling parent for an Observable
Available since: Ext JS 4.0.7
Returns
- Ext.util.Observable
The bubble parent. null is returned if no bubble target exists
Get the Record with the specified id. ...Get the Record with the specified id.
Available since: 1.1.0
Parameters
- id : String
The id of the Record to find.
Returns
- Ext.data.Model
The Record with the passed id. Returns null if not found.
Overrides: Ext.data.AbstractStore.getById
Gets the number of cached records. ...Gets the number of cached records.
If using paging, this may not be the total size of the dataset. If the data object
used by the Reader contains the dataset size, then the getTotalCount function returns
the dataset size. Note: see the Important note in load.
Available since: 1.1.0
Returns
- Number
The number of Records in the Store's cache.
Overrides: Ext.data.AbstractStore.getCount
Returns records grouped by the configured grouper configuration. ...Returns records grouped by the configured grouper configuration. Sample return value (in
this case grouping by genre and then author in a fictional books dataset):
[
{
name: 'Fantasy',
depth: 0,
records: [
//book1, book2, book3, book4
],
children: [
{
name: 'Rowling',
depth: 1,
records: [
//book1, book2
]
},
{
name: 'Tolkein',
depth: 1,
records: [
//book3, book4
]
}
]
}
]
Available since: 4.0.0
Parameters
- sort : Boolean
True to call sort before finding groups. Sorting is required to make grouping
function correctly so this should only be set to false if the Store is known to already be sorted correctly
(defaults to true)
Returns
- Object[]
The group data
Returns the string to group on for a given model instance. ...Returns the string to group on for a given model instance. The default implementation of this method returns
the model's groupField, but this can be overridden to group by an arbitrary string. For example, to
group by the first letter of a model's 'name' field, use the following code:
Ext.create('Ext.data.Store', {
groupDir: 'ASC',
getGroupString: function(instance) {
return instance.get('name')[0];
}
});
Available since: 4.0.0
Parameters
- instance : Ext.data.Model
The model instance
Returns
- String
The string to compare when forming groups
Returns an array containing the result of applying grouping to the records in this store. ...Returns an array containing the result of applying grouping to the records in this store. See groupField,
groupDir and getGroupString. Example for a store containing records with a color field:
var myStore = Ext.create('Ext.data.Store', {
groupField: 'color',
groupDir : 'DESC'
});
myStore.getGroups(); //returns:
[
{
name: 'yellow',
children: [
//all records where the color field is 'yellow'
]
},
{
name: 'red',
children: [
//all records where the color field is 'red'
]
}
]
Available since: 4.0.0
Parameters
- groupName : String (optional)
Pass in an optional groupName argument to access a specific group as defined by getGroupString
Returns
getGroupsForGrouper( records, grouper )privateFor a given set of records and a Grouper, returns an array of arrays - each of which is the set of records
matching a... This is used recursively to gather the records into the configured Groupers. ...This is used recursively to gather the records into the configured Groupers. The data MUST have been sorted for
this to work properly (see getGroupData and getGroupsForGrouper) Most of the work is done by
getGroupsForGrouper - this function largely just handles the recursion.
Available since: 4.0.0
Parameters
- records : Ext.data.Model[]
The set or subset of records to group
- grouperIndex : Number
The grouper index to retrieve
Returns
- Object[]
The grouped records
getMax( records, field )private getMin( records, field )private getNewRecords( ) : Ext.data.Model[]inherit docs
Returns all Model instances that are either currently a phantom (e.g. ...inherit docs
Returns all Model instances that are either currently a phantom (e.g. have no id), or have an ID but have not
yet been saved on this Store (this happens when adding a non-phantom record from another Store into this one)
Available since: 4.0.0
Returns
- Ext.data.Model[]
The Model instances
Overrides: Ext.data.AbstractStore.getNewRecords
Return a singleton, customized Proxy object which configures itself with a custom Reader
Returns the proxy currently...Return a singleton, customized Proxy object which configures itself with a custom Reader
Returns the proxy currently attached to this proxy instance
Available since: 4.0.0
Returns
- Ext.data.proxy.Proxy
The Proxy instance
Overrides: Ext.data.AbstractStore.getProxy
Returns a range of Records between specified indices. ...Returns a range of Records between specified indices.
Available since: 1.1.0
Parameters
- startIndex : Number (optional)
The starting index
Defaults to: 0
- endIndex : Number (optional)
The ending index. Defaults to the last Record in the Store.
Returns
- Ext.data.Model[]
An array of Records
getReader( )privateReturn a singleton, customized Reader object which reads Ext.grid.property.Property records from an object. ...Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
Available since: 4.0.0
getRemovedRecords( ) : Ext.data.Model[]Returns any records that have been removed from the store but not yet destroyed on the proxy. ...Returns any records that have been removed from the store but not yet destroyed on the proxy.
Available since: 4.0.0
Returns
- Ext.data.Model[]
The removed Model instances
getRequestId( )privateReturns a unique requestId to track requests. ...Returns a unique requestId to track requests.
Available since: 4.0.0
getSource( )privateprotected - should only be called by the grid. ...protected - should only be called by the grid. Use grid.getSource instead.
Available since: 3.4.0
getSum( records, field )private getTotalCount( ) : NumberReturns the total number of Model instances that the Proxy
indicates exist. ...Returns the total number of Model instances that the Proxy
indicates exist. This will usually differ from getCount when using paging - getCount returns the
number of records loaded into the Store at the moment, getTotalCount returns the number of records that
could be loaded into the Store if the Store contained all data
Available since: 1.1.0
Returns
- Number
The total number of Model instances available via the Proxy
getUpdatedRecords( ) : Ext.data.Model[]inherit docs
Returns all Model instances that have been updated in the Store but not yet synchronized with the Proxy ...inherit docs
Returns all Model instances that have been updated in the Store but not yet synchronized with the Proxy
Available since: 4.0.0
Returns
- Ext.data.Model[]
The updated Model instances
Overrides: Ext.data.AbstractStore.getUpdatedRecords
guaranteeRange( start, end, cb, scope )Guarantee a specific range, this will load the store with a range (that
must be the pageSize or smaller) and take car... Returns the number of pending requests out. ...Returns the number of pending requests out.
Available since: 4.0.0
Get the index within the cache of the passed Record. ...Get the index within the cache of the passed Record.
Available since: 1.1.0
Parameters
- record : Ext.data.Model
The Ext.data.Model object to find.
Returns
- Number
The index of the passed Record. Returns -1 if not found.
Get the index within the entire dataset. ...Get the index within the entire dataset. From 0 to the totalCount.
Available since: 4.0.0
Parameters
- record : Ext.data.Model
The Ext.data.Model object to find.
Returns
- Number
The index of the passed Record. Returns -1 if not found.
Initialize configuration for this class. ...Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
initSortable( )Performs initialization of this mixin. ...Performs initialization of this mixin. Component classes using this mixin should call this method during their
own initialization.
Available since: 4.0.0
insert( index, records )Inserts Model instances into the Store at the given index and fires the add event. ...Inserts Model instances into the Store at the given index and fires the add event.
See also add.
Available since: 1.1.0
Parameters
- index : Number
The start index at which to insert the passed Records.
- records : Ext.data.Model[]
An Array of Ext.data.Model objects to add to the cache.
isFiltered( ) : BooleanReturns true if this store is currently filtered ...Returns true if this store is currently filtered
Available since: 2.3.0
Returns
Overrides: Ext.data.AbstractStore.isFiltered
Checks if the store is currently grouped ...Checks if the store is currently grouped
Available since: 4.0.0
Returns
- Boolean
True if the store is grouped.
Returns true if the Store is currently performing a load operation ...Returns true if the Store is currently performing a load operation
Available since: 4.0.0
Returns
- Boolean
True if the Store is currently loading
Convenience function for getting the last model instance in the store ...Convenience function for getting the last model instance in the store
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the last record being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Ext.data.Model/undefined
The last model instance in the store, or undefined
load( [options] )Loads data into the Store via the configured proxy. ...Loads data into the Store via the configured proxy. This uses the Proxy to make an
asynchronous call to whatever storage backend the Proxy uses, automatically adding the retrieved
instances into the Store and calling an optional callback if required. Example usage:
store.load({
scope : this,
callback: function(records, operation, success) {
//the operation object contains all of the details of the load operation
console.log(records);
}
});
If the callback scope does not need to be set, a function can simply be passed:
store.load(function(records, operation, success) {
console.log('loaded records');
});
Available since: 1.1.0
Parameters
- options : Object/Function (optional)
config object, passed into the Ext.data.Operation object before loading.
Overrides: Ext.data.AbstractStore.load
loadData( data, [append] )Loads an array of data straight into the Store. ...Loads an array of data straight into the Store.
Using this method is great if the data is in the correct format already (e.g. it doesn't need to be
processed by a reader). If your data requires processing to decode the data structure, use a
MemoryProxy instead.
Available since: 1.1.0
Parameters
- data : Ext.data.Model[]/Object[]
Array of data to load. Any non-model instances will be cast
into model instances.
- append : Boolean (optional)
True to add the records to the existing records in the store, false
to remove the old ones first.
Defaults to: false
loadPage( page, options )Loads a given 'page' of data by setting the start and limit values appropriately. ... loadRawData( data, [append] )★Loads data via the bound Proxy's reader
Use this method if you are attempting to load data and want to utilize the c...Loads data via the bound Proxy's reader
Use this method if you are attempting to load data and want to utilize the configured data reader.
Available since: Ext JS 4.0.7
Parameters
loadRecords( records, options )Loads an array of model instances into the store, fires the datachanged event. ...Loads an array of model instances into the store, fires the datachanged event. This should only usually
be called internally when loading from the Proxy, when adding records manually use add instead
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of records to load
- options : Object
{addRecords: true} to add these records to the existing records, false to remove the Store's existing records first
Gets the maximum value in the store. ...Gets the maximum value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the maximum in the group being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Object
The maximum value, if no items exist, undefined.
Gets the minimum value in the store. ...Gets the minimum value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the minimum in the group being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Object
The minimum value, if no items exist, undefined.
mixin( name, cls )private mon( item, ename, [fn], [scope], [opt] )Shorthand for addManagedListener. ...Shorthand for addManagedListener.
Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is
destroyed.
Available since: 4.0.2
Parameters
- item : Ext.util.Observable/Ext.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 (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.
- opt : Object (optional)
If the ename parameter was an event name, this is the
addListener options.
mun( item, ename, [fn], [scope] )Shorthand for removeManagedListener. ...Shorthand for removeManagedListener.
Removes listeners that were added by the mon method.
Available since: 4.0.2
Parameters
- item : Ext.util.Observable/Ext.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.
nextPage( options ) on( eventName, fn, [scope], [options] )Shorthand for addListener. ...Shorthand for addListener.
Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for. May also be an object who's property names are
event names.
- fn : Function
The method the event invokes. Will be called with arguments given to
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: Unlike in ExtJS 3.x, 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.
target : 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 Components. The name of a Component
property which references an element to add a listener to.
This option is useful during Component construction to add DOM event listeners to elements of
Components which will exist only after the Component is rendered.
For example, to add a click listener to a Panel's body:
new Ext.panel.Panel({
title: 'The title',
listeners: {
click: this.handlePanelClick,
element: 'body'
}
});
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 events. For example:
myGridPanel.on({
cellClick: this.onCellClick,
mouseover: this.onMouseOver,
mouseout: this.onMouseOut,
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},
mouseover: {fn: panel.onMouseOver, scope: panel}
});
onBatchComplete( batch, operation )private onBatchException( batch, operation )private onBatchOperationComplete( batch, operation )private onCreateRecords( records, operation, success )privateCreate any new records when a write is returned from the server. ...Create any new records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of new records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
onDestroyRecords( records, operation, success )privateRemove any records when a write is returned from the server. ...Remove any records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of removed records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
onGuaranteedRange( )privateHandles a guaranteed range being loaded ...Handles a guaranteed range being loaded
Available since: 4.0.0
onProxyLoad( operation )privateCalled internally when a Proxy has completed a load request ...Called internally when a Proxy has completed a load request
Available since: 4.0.0
Parameters
- operation : Object
onProxyPrefetch( operation )privateCalled after the configured proxy completes a prefetch operation. ...Called after the configured proxy completes a prefetch operation.
Available since: 4.0.0
Parameters
- operation : Ext.data.Operation
The operation that completed
onProxyWrite( operation )privateCallback for any write Operation over the Proxy. ...Callback for any write Operation over the Proxy. Updates the Store's MixedCollection to reflect
the updates provided by the Proxy
Available since: 4.0.0
Parameters
- operation : Object
onUpdateRecords( records, operation, success )privateUpdate any records when a write is returned from the server. ...Update any records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of updated records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
onWaitForGuarantee( )privatewait until all requests finish, until guaranteeing the range. ...wait until all requests finish, until guaranteeing the range.
Available since: 4.0.0
prefetch( [options] )Prefetches data into the store using its configured proxy. ...Prefetches data into the store using its configured proxy.
Available since: 4.0.0
Parameters
- options : Object (optional)
config object, passed into the Ext.data.Operation object before loading.
See load
prefetchPage( page, [options] )Prefetches a page of data. ...Prefetches a page of data.
Available since: 4.0.0
Parameters
- page : Number
The page to prefetch
- options : Object (optional)
config object, passed into the Ext.data.Operation object before loading.
See load
previousPage( options ) purgeRecords( )Purge the least recently used records in the prefetch if the purgeCount
has been exceeded. ...Purge the least recently used records in the prefetch if the purgeCount
has been exceeded.
Available since: 4.0.0
Query the cached records in this Store using a filtering function. ...Query the cached records in this Store using a filtering function. The specified function
will be called with each record in this Store. If the function returns true the record is
included in the results.
Available since: 1.1.0
Parameters
- fn : Function
The function to be called. It will be passed the following parameters:
- record : Ext.data.Model
The record
to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- scope : Object (optional)
The scope (this reference) in which the function is executed. Defaults to this Store.
Returns
- Ext.util.MixedCollection
Returns an Ext.util.MixedCollection of the matched records
rangeSatisfied( start, end )private relayEvents( origin, events, prefix )Relays selected events from the specified Observable as if the events were fired by this. ... remove( records )private
Removes the given record from the Store, firing the 'remove' event for each instance that is removed, plus a...private
Removes the given record from the Store, firing the 'remove' event for each instance that is removed, plus a single
'datachanged' event after removal.
Available since: 3.4.0
Parameters
- records : Ext.data.Model/Ext.data.Model[]
The Ext.data.Model instance or array of instances to remove
Overrides: Ext.data.Store.remove
removeAll( silent )Remove all items from the store. ...Remove all items from the store.
Available since: 1.1.0
Parameters
- silent : Boolean
Prevent the clear event from being fired.
Overrides: Ext.data.AbstractStore.removeAll
removeAt( index )Removes the model instance at the given index ...Removes the model instance at the given index
Available since: 2.3.0
Parameters
- index : Number
The record index
removeListener( eventName, fn, [scope] )Removes an event handler. ...Removes an event handler.
Available since: 1.1.0
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 addListener or the listener will not be removed.
removeManagedListener( item, ename, [fn], [scope] )Removes listeners that were added by the mon method. ...Removes listeners that were added by the mon method.
Available since: 4.0.0
Parameters
- item : Ext.util.Observable/Ext.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 )private resumeEvents( )Resumes firing events (see suspendEvents). ...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.
Available since: 2.3.0
save( )privatedeprecated, will be removed in 5.0 ...deprecated, will be removed in 5.0
Available since: 4.0.0
Sets the Store's Proxy by string, config object or Proxy instance ...Sets the Store's Proxy by string, config object or Proxy instance
Available since: 4.0.0
Parameters
- proxy : String/Object/Ext.data.proxy.Proxy
The new Proxy, which can be either a type string, a configuration object
or an Ext.data.proxy.Proxy instance
Returns
- Ext.data.proxy.Proxy
The attached Proxy object
setSource( dataObject )privateprotected - should only be called by the grid. ...protected - should only be called by the grid. Use grid.setSource instead.
Available since: 3.4.0
Parameters
- dataObject : Object
setValue( prop, value, create )private because prefetchData is stored by index
this invalidates all of the prefetchedData
Sorts the data in the Store by on...because prefetchData is stored by index
this invalidates all of the prefetchedData
Sorts the data in the Store by one or more of its properties. 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'
}
]);
Internally, Store converts the passed arguments into an array of Ext.util.Sorter instances, and delegates
the actual sorting to its internal Ext.util.MixedCollection.
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');
Available since: 1.1.0
Parameters
- sorters : String/Ext.util.Sorter[]
Either a string name of one of the fields in this Store's configured
Model, or an array of sorter configurations.
- direction : String
The overall direction to sort the data by. Defaults to "ASC".
Returns
Overrides: Ext.util.Sortable.sort
Get the reference to the class from which this object was instantiated. ...Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
Sums the value of property for each record between start
and end and returns the result. ...Sums the value of property for each record between start
and end and returns the result.
Available since: 1.1.0
Parameters
- field : String
A field in each record
- grouped : Boolean (optional)
True to perform the operation for each group
in the store. The value returned will be an object literal with the key being the group
name and the sum for that group being the value. The grouped parameter is only honored if
the store has a groupField.
Returns
- Number
The sum
suspendEvents( queueSuspended )Suspends the firing of all events. ...Suspends the firing of all events. (see resumeEvents)
Available since: 2.3.0
Parameters
- queueSuspended : Boolean
Pass as true to queue up suspended events to be fired
after the resumeEvents call instead of discarding all suspended events.
sync( )Synchronizes the Store with its Proxy. ...Synchronizes the Store with its Proxy. This asks the Proxy to batch together any new, updated
and deleted records in the store, updating the Store's internal representation of the records
as each operation completes.
Available since: 4.0.0
un( eventName, fn, [scope] )Shorthand for removeListener. ...Shorthand for removeListener.
Removes an event handler.
Available since: 1.1.0
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 addListener or the listener will not be removed.
Creates new property store.
Available since: 1.1.0
Parameters
- grid : Ext.grid.Panel
The grid this store will be bound to
- source : Object
The source data config object
Returns
Overrides: Ext.data.Store.constructor
Adds Model instance to the Store. This method accepts either:
- An array of Model instances or Model configuration objects.
- Any number of Model instance or Model configuration object arguments.
The new Model instances will be added at the end of the existing collection.
Sample usage:
myStore.add({some: 'data'}, {some: 'other data'});
Available since: 1.1.0
Parameters
- model : Ext.data.Model[]/Ext.data.Model...
An array of Model instances or Model configuration objects, or variable number of Model instance or config arguments.
Returns
- Ext.data.Model[]
The model instances that were added
Adds the specified events to the list of events which this Observable may fire.
Available since: 1.1.0
Parameters
- o : Object/String
Either an object with event names as properties with a value of
trueor the first event name string if multiple event names are being passed as separate parameters. Usage:this.addEvents({ storeloaded: true, storecleared: true }); - more : String... (optional)
Additional event names if multiple event names are being passed as separate parameters. Usage:
this.addEvents('storeloaded', 'storecleared');
Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for. May also be an object who's property names are event names.
- fn : Function
The method the event invokes. Will be called with arguments given to fireEvent plus the
optionsparameter described below. - scope : Object (optional)
The scope (
thisreference) 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: Unlike in ExtJS 3.x, 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 (
thisreference) 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.
target : 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 Components. The name of a Component property which references an element to add a listener to.
This option is useful during Component construction to add DOM event listeners to elements of Components which will exist only after the Component is rendered. For example, to add a click listener to a Panel's body:
new Ext.panel.Panel({ title: 'The title', listeners: { click: this.handlePanelClick, element: 'body' } });
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 events. For example:
myGridPanel.on({ cellClick: this.onCellClick, mouseover: this.onMouseOver, mouseout: this.onMouseOut, 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}, mouseover: {fn: panel.onMouseOver, scope: panel} });
Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is destroyed.
Available since: 4.0.0
Parameters
- item : Ext.util.Observable/Ext.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 (optional)
If the
enameparameter was an event name, this is the handler function. - scope : Object (optional)
If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed. - opt : Object (optional)
If the
enameparameter was an event name, this is the addListener options.
A model instance should call this method on the Store it has been joined to.
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
A model instance should call this method on the Store it has been joined to.
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
A model instance should call this method on the Store it has been joined to..
Available since: Ext 3
Parameters
- record : Ext.data.Model
The model instance that was edited
Runs the aggregate function for all the records in the store.
Available since: 4.0.0
Parameters
- fn : Function
The function to execute. The function is called with a single parameter, an array of records for that group.
- scope : Object (optional)
The scope to execute the function in. Defaults to the store.
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the group average being the value. The grouped parameter is only honored if the store has a groupField.
- args : Array (optional)
Any arguments to append to the function call
Returns
- Object
An object literal with the group names and their appropriate values.
Gets the average value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the group average being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Object
The average value, if no items exist, 0.
Caches the records in the prefetch and stripes them with their server-side index.
Available since: 4.0.0
Parameters
- records : Ext.data.Model[]
The records to cache
- The : Ext.data.Operation
associated operation
Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject from the current method, for example:this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
Revert to a view of the Record cache with no filtering applied.
Available since: 1.1.0
Parameters
- suppressEvent : Boolean
If true the filter is cleared silently without firing the datachanged event.
Overrides: Ext.data.AbstractStore.clearFilter
Removes all listeners for this object including the managed listeners
Available since: 4.0.0
Removes all managed listeners for this object.
Available since: 4.0.0
Collects unique values for a particular dataIndex from this store.
Available since: 1.1.0
Parameters
- dataIndex : String
The property to collect
- allowNull : Boolean (optional)
Pass true to allow null, undefined or empty string values
- bypassFilter : Boolean (optional)
Pass true to collect from all records, even ones which are filtered
Returns
- Object[]
An array of the unique values
Gets the count of items in the store.
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the count for each group being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Number
the count
Returns a filter function used to test a the given property's value. Defers most of the work to Ext.util.MixedCollection's createValueMatcher function
Available since: 3.4.0
Parameters
- property : String
The property to create the filter function for
- value : String/RegExp
The string/regex to compare the property value to
- anyMatch : Boolean (optional)
True if we don't care if the filter value is not the full value.
Defaults to:
false - caseSensitive : Boolean (optional)
True to create a case-sensitive regex.
Defaults to:
false - exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex). Ignored if anyMatch is true.
Defaults to:
false
Converts a literal to a model, if it's not a model already
Available since: 4.0.0
Parameters
- record : Object
{Ext.data.Model/Object} The record to create
Returns
Normalizes an array of filter objects, ensuring that they are all Ext.util.Filter instances
Available since: 4.0.0
Parameters
- filters : Object[]
The filters array
Returns
- Ext.util.Filter[]
Array of Ext.util.Filter objects
Normalizes an array of grouper objects, ensuring that they are all Ext.util.Grouper instances
Available since: 4.0.0
Parameters
- groupers : Object[]
The groupers array
Returns
- Ext.util.Grouper[]
Array of Ext.util.Grouper objects
Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances
Available since: 4.0.0
Parameters
- sorters : Object[]
The sorters array
Returns
- Ext.util.Sorter[]
Array of Ext.util.Sorter objects
tells the attached proxy to destroy the given records
Available since: Ext 3
Parameters
- options : Object
overriden to provide striping of the indexes as sorting occurs. this cannot be done inside of sort because datachanged has already fired and will trigger a repaint of the bound view.
Available since: 4.0.0
Parameters
- sorterFn : Object
Overrides: Ext.data.AbstractStore.doSort
Calls the specified function for each of the Records in the cache.
Available since: 1.1.0
Parameters
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.override(Ext.form.field.Base, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.Function.createSequence(Ext.form.field.Base.prototype.initComponent, function() {
this.enableBubble('change');
}),
// We know that we want Field's events to bubble directly to the FormPanel.
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
// Title goes red if form has been modified.
myForm.header.setStyle('color', 'red');
}
}
});
Available since: 3.4.0
Parameters
Filters the loaded set of records by a given set of filters.
Filtering by single field:
store.filter("email", /\.com$/);
Using multiple filters:
store.filter([
{property: "email", value: /\.com$/},
{filterFn: function(item) { return item.get("age") > 10; }}
]);
Using Ext.util.Filter instances instead of config objects (note that we need to specify the root config option in this case):
store.filter([
Ext.create('Ext.util.Filter', {property: "email", value: /\.com$/, root: 'data'}),
Ext.create('Ext.util.Filter', {filterFn: function(item) { return item.get("age") > 10; }, root: 'data'})
]);
Available since: 1.1.0
Parameters
- filters : Object[]/Ext.util.Filter[]/String
The set of filters to apply to the data. These are stored internally on the store, but the filtering itself is done on the Store's MixedCollection. See MixedCollection's filter method for filter syntax. Alternatively, pass in a property string
- value : String (optional)
value to filter by (only if using a property string as the first argument)
Overrides: Ext.data.AbstractStore.filter
Filter by a function. The specified function will be called for each Record in this Store. If the function returns true the Record is included, otherwise it is filtered out.
Available since: 1.1.0
Parameters
- fn : Function
The function to be called. It will be passed the following parameters:
- record : Ext.data.Model
The record to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- record : Ext.data.Model
- scope : Object (optional)
The scope (
thisreference) in which the function is executed. Defaults to this Store.
Overrides: Ext.data.AbstractStore.filterBy
Finds the index of the first matching Record in this store by a specific field value.
Available since: 2.3.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : String/RegExp
Either a string that the field value should begin with, or a RegExp to test against the field.
- startIndex : Number (optional)
The index to start searching at
- anyMatch : Boolean (optional)
True to match any part of the string, not just the beginning
- caseSensitive : Boolean (optional)
True for case sensitive comparison
- exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex). Defaults to false.
Returns
- Number
The matched index or -1
Find the index of the first matching Record in this Store 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. It will be passed the following parameters:
- record : Ext.data.Model
The record to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- record : Ext.data.Model
- scope : Object (optional)
The scope (
thisreference) in which the function is executed. Defaults to this Store. - startIndex : Number (optional)
The index to start searching at
Returns
- Number
The matched index or -1
Finds the index of the first matching Record in this store by a specific field value.
Available since: 3.4.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : Object
The value to match the field against.
- startIndex : Number (optional)
The index to start searching at
Returns
- Number
The matched index or -1
Finds the first matching Record in this store by a specific field value.
Available since: 4.0.0
Parameters
- fieldName : String
The name of the Record field to test.
- value : String/RegExp
Either a string that the field value should begin with, or a RegExp to test against the field.
- startIndex : Number (optional)
The index to start searching at
- anyMatch : Boolean (optional)
True to match any part of the string, not just the beginning
- caseSensitive : Boolean (optional)
True for case sensitive comparison
- exactMatch : Boolean (optional)
True to force exact match (^ and $ characters added to the regex). Defaults to false.
Returns
- Ext.data.Model
The matched record or null
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.
Available since: 1.1.0
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.
Fires the groupchange event. Abstracted out so we can use it as a callback
Available since: 4.0.0
Convenience function for getting the first model instance in the store
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the first record being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Ext.data.Model/undefined
The first model instance in the store, or undefined
Get the Record at the specified index.
Available since: 1.1.0
Parameters
- index : Number
The index of the Record to find.
Returns
- Ext.data.Model
The Record at the passed index. Returns undefined if not found.
Returns an object which is passed in as the listeners argument to proxy.batch inside this.sync. This is broken out into a separate function to allow for customisation of the listeners
Available since: 4.0.0
Returns
- Object
The listeners object
Gets the bubbling parent for an Observable
Available since: Ext JS 4.0.7
Returns
- Ext.util.Observable
The bubble parent. null is returned if no bubble target exists
Get the Record with the specified id.
Available since: 1.1.0
Parameters
- id : String
The id of the Record to find.
Returns
- Ext.data.Model
The Record with the passed id. Returns null if not found.
Overrides: Ext.data.AbstractStore.getById
Gets the number of cached records.
If using paging, this may not be the total size of the dataset. If the data object used by the Reader contains the dataset size, then the getTotalCount function returns the dataset size. Note: see the Important note in load.
Available since: 1.1.0
Returns
- Number
The number of Records in the Store's cache.
Overrides: Ext.data.AbstractStore.getCount
Returns records grouped by the configured grouper configuration. Sample return value (in this case grouping by genre and then author in a fictional books dataset):
[
{
name: 'Fantasy',
depth: 0,
records: [
//book1, book2, book3, book4
],
children: [
{
name: 'Rowling',
depth: 1,
records: [
//book1, book2
]
},
{
name: 'Tolkein',
depth: 1,
records: [
//book3, book4
]
}
]
}
]
Available since: 4.0.0
Parameters
- sort : Boolean
True to call sort before finding groups. Sorting is required to make grouping function correctly so this should only be set to false if the Store is known to already be sorted correctly (defaults to true)
Returns
- Object[]
The group data
Returns the string to group on for a given model instance. The default implementation of this method returns the model's groupField, but this can be overridden to group by an arbitrary string. For example, to group by the first letter of a model's 'name' field, use the following code:
Ext.create('Ext.data.Store', {
groupDir: 'ASC',
getGroupString: function(instance) {
return instance.get('name')[0];
}
});
Available since: 4.0.0
Parameters
- instance : Ext.data.Model
The model instance
Returns
- String
The string to compare when forming groups
Returns an array containing the result of applying grouping to the records in this store. See groupField, groupDir and getGroupString. Example for a store containing records with a color field:
var myStore = Ext.create('Ext.data.Store', {
groupField: 'color',
groupDir : 'DESC'
});
myStore.getGroups(); //returns:
[
{
name: 'yellow',
children: [
//all records where the color field is 'yellow'
]
},
{
name: 'red',
children: [
//all records where the color field is 'red'
]
}
]
Available since: 4.0.0
Parameters
- groupName : String (optional)
Pass in an optional groupName argument to access a specific group as defined by getGroupString
Returns
This is used recursively to gather the records into the configured Groupers. The data MUST have been sorted for this to work properly (see getGroupData and getGroupsForGrouper) Most of the work is done by getGroupsForGrouper - this function largely just handles the recursion.
Available since: 4.0.0
Parameters
- records : Ext.data.Model[]
The set or subset of records to group
- grouperIndex : Number
The grouper index to retrieve
Returns
- Object[]
The grouped records
inherit docs
Returns all Model instances that are either currently a phantom (e.g. have no id), or have an ID but have not yet been saved on this Store (this happens when adding a non-phantom record from another Store into this one)
Available since: 4.0.0
Returns
- Ext.data.Model[]
The Model instances
Overrides: Ext.data.AbstractStore.getNewRecords
Return a singleton, customized Proxy object which configures itself with a custom Reader
Returns the proxy currently attached to this proxy instance
Available since: 4.0.0
Returns
- Ext.data.proxy.Proxy
The Proxy instance
Overrides: Ext.data.AbstractStore.getProxy
Returns a range of Records between specified indices.
Available since: 1.1.0
Parameters
- startIndex : Number (optional)
The starting index
Defaults to:
0 - endIndex : Number (optional)
The ending index. Defaults to the last Record in the Store.
Returns
- Ext.data.Model[]
An array of Records
Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.
Available since: 4.0.0
Returns any records that have been removed from the store but not yet destroyed on the proxy.
Available since: 4.0.0
Returns
- Ext.data.Model[]
The removed Model instances
Returns a unique requestId to track requests.
Available since: 4.0.0
protected - should only be called by the grid. Use grid.getSource instead.
Available since: 3.4.0
Returns the total number of Model instances that the Proxy indicates exist. This will usually differ from getCount when using paging - getCount returns the number of records loaded into the Store at the moment, getTotalCount returns the number of records that could be loaded into the Store if the Store contained all data
Available since: 1.1.0
Returns
- Number
The total number of Model instances available via the Proxy
inherit docs
Returns all Model instances that have been updated in the Store but not yet synchronized with the Proxy
Available since: 4.0.0
Returns
- Ext.data.Model[]
The updated Model instances
Overrides: Ext.data.AbstractStore.getUpdatedRecords
Returns the number of pending requests out.
Available since: 4.0.0
Get the index within the cache of the passed Record.
Available since: 1.1.0
Parameters
- record : Ext.data.Model
The Ext.data.Model object to find.
Returns
- Number
The index of the passed Record. Returns -1 if not found.
Get the index within the entire dataset. From 0 to the totalCount.
Available since: 4.0.0
Parameters
- record : Ext.data.Model
The Ext.data.Model object to find.
Returns
- Number
The index of the passed Record. Returns -1 if not found.
Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
Performs initialization of this mixin. Component classes using this mixin should call this method during their own initialization.
Available since: 4.0.0
Inserts Model instances into the Store at the given index and fires the add event.
See also add.
Available since: 1.1.0
Parameters
- index : Number
The start index at which to insert the passed Records.
- records : Ext.data.Model[]
An Array of Ext.data.Model objects to add to the cache.
Returns true if this store is currently filtered
Available since: 2.3.0
Returns
Overrides: Ext.data.AbstractStore.isFiltered
Checks if the store is currently grouped
Available since: 4.0.0
Returns
- Boolean
True if the store is grouped.
Returns true if the Store is currently performing a load operation
Available since: 4.0.0
Returns
- Boolean
True if the Store is currently loading
Convenience function for getting the last model instance in the store
Available since: 4.0.0
Parameters
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the last record being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Ext.data.Model/undefined
The last model instance in the store, or undefined
Loads data into the Store via the configured proxy. This uses the Proxy to make an asynchronous call to whatever storage backend the Proxy uses, automatically adding the retrieved instances into the Store and calling an optional callback if required. Example usage:
store.load({
scope : this,
callback: function(records, operation, success) {
//the operation object contains all of the details of the load operation
console.log(records);
}
});
If the callback scope does not need to be set, a function can simply be passed:
store.load(function(records, operation, success) {
console.log('loaded records');
});
Available since: 1.1.0
Parameters
- options : Object/Function (optional)
config object, passed into the Ext.data.Operation object before loading.
Overrides: Ext.data.AbstractStore.load
Loads an array of data straight into the Store.
Using this method is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your data requires processing to decode the data structure, use a MemoryProxy instead.
Available since: 1.1.0
Parameters
- data : Ext.data.Model[]/Object[]
Array of data to load. Any non-model instances will be cast into model instances.
- append : Boolean (optional)
True to add the records to the existing records in the store, false to remove the old ones first.
Defaults to:
false
Loads data via the bound Proxy's reader
Use this method if you are attempting to load data and want to utilize the configured data reader.
Available since: Ext JS 4.0.7
Parameters
Loads an array of model instances into the store, fires the datachanged event. This should only usually be called internally when loading from the Proxy, when adding records manually use add instead
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of records to load
- options : Object
{addRecords: true} to add these records to the existing records, false to remove the Store's existing records first
Gets the maximum value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the maximum in the group being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Object
The maximum value, if no items exist, undefined.
Gets the minimum value in the store.
Available since: 4.0.0
Parameters
- field : String
The field in each record
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the minimum in the group being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Object
The minimum value, if no items exist, undefined.
Shorthand for addManagedListener.
Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is destroyed.
Available since: 4.0.2
Parameters
- item : Ext.util.Observable/Ext.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 (optional)
If the
enameparameter was an event name, this is the handler function. - scope : Object (optional)
If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed. - opt : Object (optional)
If the
enameparameter was an event name, this is the addListener options.
Shorthand for removeManagedListener.
Removes listeners that were added by the mon method.
Available since: 4.0.2
Parameters
- item : Ext.util.Observable/Ext.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
enameparameter was an event name, this is the handler function. - scope : Object (optional)
If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed.
Shorthand for addListener.
Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for. May also be an object who's property names are event names.
- fn : Function
The method the event invokes. Will be called with arguments given to fireEvent plus the
optionsparameter described below. - scope : Object (optional)
The scope (
thisreference) 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: Unlike in ExtJS 3.x, 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 (
thisreference) 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.
target : 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 Components. The name of a Component property which references an element to add a listener to.
This option is useful during Component construction to add DOM event listeners to elements of Components which will exist only after the Component is rendered. For example, to add a click listener to a Panel's body:
new Ext.panel.Panel({ title: 'The title', listeners: { click: this.handlePanelClick, element: 'body' } });
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 events. For example:
myGridPanel.on({ cellClick: this.onCellClick, mouseover: this.onMouseOver, mouseout: this.onMouseOut, 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}, mouseover: {fn: panel.onMouseOver, scope: panel} });
Create any new records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of new records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
Remove any records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of removed records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
Handles a guaranteed range being loaded
Available since: 4.0.0
Called internally when a Proxy has completed a load request
Available since: 4.0.0
Parameters
- operation : Object
Called after the configured proxy completes a prefetch operation.
Available since: 4.0.0
Parameters
- operation : Ext.data.Operation
The operation that completed
Callback for any write Operation over the Proxy. Updates the Store's MixedCollection to reflect the updates provided by the Proxy
Available since: 4.0.0
Parameters
- operation : Object
Update any records when a write is returned from the server.
Available since: 3.4.0
Parameters
- records : Ext.data.Model[]
The array of updated records
- operation : Ext.data.Operation
The operation that just completed
- success : Boolean
True if the operation was successful
wait until all requests finish, until guaranteeing the range.
Available since: 4.0.0
Prefetches data into the store using its configured proxy.
Available since: 4.0.0
Parameters
- options : Object (optional)
config object, passed into the Ext.data.Operation object before loading. See load
Prefetches a page of data.
Available since: 4.0.0
Parameters
- page : Number
The page to prefetch
- options : Object (optional)
config object, passed into the Ext.data.Operation object before loading. See load
Purge the least recently used records in the prefetch if the purgeCount has been exceeded.
Available since: 4.0.0
Query the cached records in this Store using a filtering function. The specified function will be called with each record in this Store. If the function returns true the record is included in the results.
Available since: 1.1.0
Parameters
- fn : Function
The function to be called. It will be passed the following parameters:
- record : Ext.data.Model
The record to test for filtering. Access field values using Ext.data.Model.get.
- id : Object
The ID of the Record passed.
- record : Ext.data.Model
- scope : Object (optional)
The scope (
thisreference) in which the function is executed. Defaults to this Store.
Returns
- Ext.util.MixedCollection
Returns an Ext.util.MixedCollection of the matched records
private
Removes the given record from the Store, firing the 'remove' event for each instance that is removed, plus a single 'datachanged' event after removal.
Available since: 3.4.0
Parameters
- records : Ext.data.Model/Ext.data.Model[]
The Ext.data.Model instance or array of instances to remove
Overrides: Ext.data.Store.remove
Remove all items from the store.
Available since: 1.1.0
Parameters
- silent : Boolean
Prevent the
clearevent from being fired.
Overrides: Ext.data.AbstractStore.removeAll
Removes the model instance at the given index
Available since: 2.3.0
Parameters
- index : Number
The record index
Removes an event handler.
Available since: 1.1.0
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 addListener or the listener will not be removed.
Removes listeners that were added by the mon method.
Available since: 4.0.0
Parameters
- item : Ext.util.Observable/Ext.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
enameparameter was an event name, this is the handler function. - scope : Object (optional)
If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed.
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.
Available since: 2.3.0
deprecated, will be removed in 5.0
Available since: 4.0.0
Sets the Store's Proxy by string, config object or Proxy instance
Available since: 4.0.0
Parameters
- proxy : String/Object/Ext.data.proxy.Proxy
The new Proxy, which can be either a type string, a configuration object or an Ext.data.proxy.Proxy instance
Returns
- Ext.data.proxy.Proxy
The attached Proxy object
protected - should only be called by the grid. Use grid.setSource instead.
Available since: 3.4.0
Parameters
- dataObject : Object
because prefetchData is stored by index this invalidates all of the prefetchedData
Sorts the data in the Store by one or more of its properties. 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'
}
]);
Internally, Store converts the passed arguments into an array of Ext.util.Sorter instances, and delegates the actual sorting to its internal Ext.util.MixedCollection.
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');
Available since: 1.1.0
Parameters
- sorters : String/Ext.util.Sorter[]
Either a string name of one of the fields in this Store's configured Model, or an array of sorter configurations.
- direction : String
The overall direction to sort the data by. Defaults to "ASC".
Returns
Overrides: Ext.util.Sortable.sort
Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
Sums the value of property for each record between start and end and returns the result.
Available since: 1.1.0
Parameters
- field : String
A field in each record
- grouped : Boolean (optional)
True to perform the operation for each group in the store. The value returned will be an object literal with the key being the group name and the sum for that group being the value. The grouped parameter is only honored if the store has a groupField.
Returns
- Number
The sum
Suspends the firing of all events. (see resumeEvents)
Available since: 2.3.0
Parameters
- queueSuspended : Boolean
Pass as true to queue up suspended events to be fired after the resumeEvents call instead of discarding all suspended events.
Synchronizes the Store with its Proxy. This asks the Proxy to batch together any new, updated and deleted records in the store, updating the Store's internal representation of the records as each operation completes.
Available since: 4.0.0
Shorthand for removeListener.
Removes an event handler.
Available since: 1.1.0
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 addListener or the listener will not be removed.
Static Methods Add / override static properties of this class. ...Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class. ...Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class. ...Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
createAlias( alias, origin )staticCreate aliases for existing prototype methods. ...Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See
flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format. ...Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
implement( members )staticAdd methods / properties to the prototype of this class. ...Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. ...Override prototype members of this class. Overridden methods can be invoked via
callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. Overridden methods can be invoked via callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Events
Fired when a Model instance has been added to this Store
Available since: Ext 1
Parameters
- store : Ext.data.Store
The store
- records : Ext.data.Model[]
The Model instances that were added
- index : Number
The index at which the instances were inserted
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires before a request is made for a new data object. If the beforeload handler returns false the load action will be canceled.
Available since: Ext 1
Parameters
- store : Ext.data.Store
This Store
- operation : Ext.data.Operation
The Ext.data.Operation object that will be passed to the Proxy to load the Store
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires before a prefetch occurs. Return false to cancel.
Available since: 4.0.0
Parameters
- this : Ext.data.Store
- operation : Ext.data.Operation
The associated operation
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fired before a call to sync is executed. Return false from any listener to cancel the synv
Available since: 4.0.0
Parameters
- options : Object
Hash of all records to be synchronized, broken down into create, update and destroy
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fired after the removeAll method is called.
Available since: Ext 1
Parameters
- this : Ext.data.Store
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires whenever the records in the Store have changed in some way - this could include adding or removing records, or updating the data in existing records
Available since: Ext 1
Parameters
- this : Ext.data.Store
The data store
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fired whenever the grouping in the grid changes
Available since: 4.0.0
Parameters
- store : Ext.data.Store
The store
- groupers : Ext.util.Grouper[]
The array of grouper objects
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires whenever records have been prefetched
Available since: 1.1.0
Parameters
- this : Ext.data.Store
- records : Ext.util.Grouper[]
An array of records
- successful : Boolean
True if the operation was successful.
- operation : Ext.data.Operation
The associated operation
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Overrides: Ext.data.AbstractStore.load
Fired when a Model instance has been removed from this Store
Available since: Ext 1
Parameters
- store : Ext.data.Store
The Store object
- record : Ext.data.Model
The record that was removed
- index : Number
The index of the record that was removed
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires when a Model instance has been updated
Available since: Ext 1
Parameters
- this : Ext.data.Store
- record : Ext.data.Model
The Model instance that was updated
- operation : String
The update operation being performed. Value may be one of:
Ext.data.Model.EDIT Ext.data.Model.REJECT Ext.data.Model.COMMIT - eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires whenever a successful write has been made via the configured Proxy
Available since: Ext 3
Parameters
- store : Ext.data.Store
This Store
- operation : Ext.data.Operation
The Operation object that was used in the write
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.