Observable Store ArrayStore
Package: | Ext.data |
Defined In: | ArrayStore.js |
Class: | ArrayStore |
Extends: | Store |
xtype: | arraystore |
Formerly known as "SimpleStore".
Small helper class to make creating Ext.data.Stores from Array data easier. An ArrayStore will be automatically configured with a Ext.data.ArrayReader.
A store configuration would be something like:
var store = new Ext.data.ArrayStore({
// store configs
autoDestroy: true,
storeId: 'myStore',
// reader configs
idIndex: 0,
fields: [
'company',
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
});
This store is configured to consume a returned object of the form:
var myData = [
['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
];
An object literal of this form could also be used as the data config option.
*Note: Although not listed here, this class accepts all of the configuration options of ArrayReader.
Config Options | Defined By | |
---|---|---|
autoDestroy : Boolean true to destroy the store when the component the store is bound
to is destroyed (defaults to false).
Note: this shoul... true to destroy the store when the component the store is bound
to is destroyed (defaults to false).
Note: this should be set to true when using stores that are bound to only 1 component. | Store | |
autoLoad : Boolean/Object If data is not specified, and if autoLoad
is true or an Object, this store's load method is automatically called
afte... | Store | |
autoSave : Boolean Defaults to true causing the store to automatically save records to
the server when a record is modified (ie: becomes... | Store | |
baseParams : Object An object containing properties which are to be sent as parameters
for every HTTP request.
Parameters are encoded as ... An object containing properties which are to be sent as parameters for every HTTP request. Parameters are encoded as standard HTTP parameters using Ext.urlEncode. Note: setBaseParam
method. | Store | |
batch : Boolean Defaults to true (unless restful:true). Multiple
requests for each CRUD action (CREATE, READ, UPDATE and DESTROY) wil... Defaults to true (unless If Store is RESTful, the DataProxy is also RESTful, and a unique transaction is generated for each record. | Store | |
data : Array | Store | |
defaultParamNames : Object Provides the default values for the paramNames property. To globally modify the parameters
for all stores, this objec... Provides the default values for the paramNames property. To globally modify the parameters
for all stores, this object should be changed on the store prototype. | Store | |
listeners : Object A config object containing one or more event handlers to be added to this
object during initialization. This should ... 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 ExtJs Components While some ExtJs 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
| Observable | |
paramNames : Object An object containing properties which specify the names of the paging and
sorting parameters passed to remote servers... An object containing properties which specify the names of the paging and sorting parameters passed to remote servers when loading blocks of data. By default, this object takes the following form:
The server must produce the requested data block upon receipt of these parameter names. If different parameter names are required, this property can be overriden using a configuration property. A PagingToolbar bound to this Store uses this property to determine the parameter names to use in its requests. | Store | |
proxy : Ext.data.DataProxy | Store | |
pruneModifiedRecords : Boolean true to clear all modified record information each time
the store is loaded or when a record is removed (defaults to ... true to clear all modified record information each time
the store is loaded or when a record is removed (defaults to false). See getModifiedRecords
for the accessor method to retrieve the modified records. | Store | |
remoteSort : boolean true if sorting is to be handled by requesting the Proxy
to provide a refreshed version of the data object in sorted ... true if sorting is to be handled by requesting the Proxy
to provide a refreshed version of the data object in sorted order, as opposed to sorting the Record cache
in place (defaults to false).
If remoteSort is true, then clicking on a Grid Column's header causes the current page to be requested from the server appending the following two parameters to the params:
| Store | |
restful : Boolean Defaults to false. Set to true to have the Store and the set
Proxy operate in a RESTful manner. The store will autom... Defaults to false. Set to true to have the Store and the set
Proxy operate in a RESTful manner. The store will automatically generate GET, POST,
PUT and DELETE requests to the server. The HTTP method used for any given CRUD
action is described in Ext.data.Api.restActions. For additional information
see Ext.data.DataProxy.restful.
Note: if | Store | |
sortInfo : Object A config object to specify the sort order in the request of a Store's
load operation. Note that for local sorting, t... A config object to specify the sort order in the request of a Store's
load operation. Note that for local sorting, the direction property is
case-sensitive. See also remoteSort and paramNames.
For example:
| Store | |
storeId : String | Store | |
url : String | Store | |
writer : Ext.data.DataWriter The Writer object which processes a record object for being written
to the server-side database.
When a writer is ins... The Writer object which processes a record object for being written to the server-side database. When a writer is installed into a Store the add, remove, and update events on the store are monitored in order to remotely create records, destroy records, or update records. The proxy for this store will relay any writexception events to this store. Sample implementation:
| Store |
Property | Defined By | |
---|---|---|
baseParams : Object See the corresponding configuration option
for a description of this property.
To modify this property see setBasePar... See the corresponding configuration option
for a description of this property.
To modify this property see setBaseParam . | Store | |
fields : Ext.util.MixedCollection | Store | |
lastOptions : Object Contains the last options object used as the parameter to the load method. See load
for the details of what this may ... | Store | |
recordType : Function The Record constructor as supplied to (or created by) the
Reader. Read-only.
If the Reader was constructed by passing... The Record constructor as supplied to (or created by) the
Reader. Read-only.
If the Reader was constructed by passing in an Array of Ext.data.Field definition objects, instead of a Record constructor, it will implicitly create a Record constructor from that Array (see Ext.data.Record.create for additional details). This property may be used to create new Records of the type held in this Store, for example:
| Store |
Method | Defined By | |||
---|---|---|---|---|
ArrayStore( Object config )
Parameters:
| ArrayStore | |||
add( Ext.data.Record[] records )
:
voidAdd Records to the Store and fires the add event. To add Records
to the store from a remote source use load({add:tru... Add Records to the Store and fires the add event. To add Records
to the store from a remote source use load({add:true}) .
See also recordType and insert .Parameters:
| Store | |||
addEvents( Object|String o , string Optional. )
:
voidAdds 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. Parameters:
| Observable | |||
addListener( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object. Appends an event handler to this object. Parameters:
| Observable | |||
addSorted( Ext.data.Record record )
:
void(Local sort only) Inserts the passed Record into the Store at the index where it
should go based on the current sort ... (Local sort only) Inserts the passed Record into the Store at the index where it
should go based on the current sort information. Parameters:
| Store | |||
clearFilter( Boolean suppressEvent )
:
voidRevert to a view of the Record cache with no filtering applied. Revert to a view of the Record cache with no filtering applied. Parameters:
| Store | |||
collect( String dataIndex , [Boolean allowNull ], [Boolean bypassFilter ] )
:
ArrayCollects unique values for a particular dataIndex from this store. Collects unique values for a particular dataIndex from this store. Parameters:
| Store | |||
commitChanges()
:
void Commit all Records with outstanding changes. To handle updates for changes,
subscribe to the Store's update event, an... Commit all Records with outstanding changes. To handle updates for changes,
subscribe to the Store's update event, and perform updating when the third parameter is
Ext.data.Record.COMMIT. Parameters:
| Store | |||
destroy()
:
void Destroys the store. Destroys the store. Parameters:
| Store | |||
each( Function fn , [Object scope ] )
:
voidCalls the specified function for each of the Records in the cache. Calls the specified function for each of the Records in the cache. | Store | |||
enableBubble( Object events )
:
voidEnables 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 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:
Parameters:
| Observable | |||
filter( String field , String/RegExp value , [Boolean anyMatch ], [Boolean caseSensitive ] )
:
voidFilter the records by a specified property. Filter the records by a specified property. Parameters:
| Store | |||
filterBy( Function fn , [Object scope ] )
:
voidFilter by a function. The specified function will be called for each
Record in this Store. If the function returns tr... 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. Parameters:
| Store | |||
find( String property , String/RegExp value , [Number startIndex ], [Boolean anyMatch ], [Boolean caseSensitive ] )
:
NumberFinds the index of the first matching record in this store by a specific property/value. Finds the index of the first matching record in this store by a specific property/value. Parameters:
| Store | |||
findBy( Function fn , [Object scope ], [Number startIndex ] )
:
NumberFind the index of the first matching Record in this Store by a function.
If the function returns true it is considere... Find the index of the first matching Record in this Store by a function.
If the function returns true it is considered a match. Parameters:
| Store | |||
findExact( String property , String/RegExp value , [Number startIndex ] )
:
NumberFinds the index of the first matching record in this store by a specific property/value. Finds the index of the first matching record in this store by a specific property/value. Parameters:
| Store | |||
fireEvent( String eventName , Object... args )
:
BooleanFires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Obse... Fires the specified event with the passed parameters (minus the event name). An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble. Parameters:
| Observable | |||
getAt( Number index )
:
Ext.data.RecordGet the Record at the specified index. Get the Record at the specified index. Parameters:
| Store | |||
getById( String id )
:
Ext.data.RecordGet the Record with the specified id. Get the Record with the specified id. Parameters:
| Store | |||
getCount()
:
Number Gets the number of cached records.
If using paging, this may not be the total size of the dataset. If the data object... 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. Parameters:
| Store | |||
getModifiedRecords()
:
Ext.data.Record[] Gets all records modified since the last commit. Modified records are
persisted across load operations (e.g., during... Gets all records modified since the last commit. Modified records are
persisted across load operations (e.g., during paging). Note: deleted records are not
included. See also pruneModifiedRecords and
Ext.data.RecordmarkDirty.. Parameters:
| Store | |||
getRange( [Number startIndex ], [Number endIndex ] )
:
Ext.data.Record[]Returns a range of Records between specified indices. Returns a range of Records between specified indices. Parameters:
| Store | |||
getSortState()
:
Object Returns an object describing the current sort state of this Store. Returns an object describing the current sort state of this Store. Parameters:
| Store | |||
getTotalCount()
:
Number Gets the total number of records in the dataset as returned by the server.
If using paging, for this to be accurate, ... Gets the total number of records in the dataset as returned by the server.
If using paging, for this to be accurate, the data object used by the Reader must contain the dataset size. For remote data sources, the value for this property (totalProperty for JsonReader, totalRecords for XmlReader) shall be returned by a query on the server. Note: see the Important note in load. Parameters:
| Store | |||
hasListener( String eventName )
:
BooleanChecks to see if this object has any listeners for a specified event Checks to see if this object has any listeners for a specified event Parameters:
| Observable | |||
indexOf( Ext.data.Record record )
:
NumberGet the index within the cache of the passed Record. Get the index within the cache of the passed Record. Parameters:
| Store | |||
indexOfId( String id )
:
NumberGet the index within the cache of the Record with the passed id. Get the index within the cache of the Record with the passed id. Parameters:
| Store | |||
insert( Number index , Ext.data.Record[] records )
:
voidInserts Records into the Store at the given index and fires the add event.
See also add and addSorted. | Store | |||
isFiltered()
:
Boolean Returns true if this store is currently filtered Returns true if this store is currently filtered Parameters:
| Store | |||
load( Object options )
:
BooleanLoads the Record cache from the configured proxy using the configured reader.
Notes:<div class="mdetail-params">
Impo... Loads the Record cache from the configured proxy using the configured reader. Notes:
Parameters:
| Store | |||
loadData( Object data , [Boolean append ] )
:
voidLoads data from a passed data block and fires the load event. A Reader
which understands the format of the data must ... Loads data from a passed data block and fires the load event. A Reader
which understands the format of the data must have been configured in the constructor. Parameters:
| Store | |||
on( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object (shorthand for addListener.) Appends an event handler to this object (shorthand for addListener.) Parameters:
| Observable | |||
purgeListeners()
:
void Removes all listeners for this object Removes all listeners for this object Parameters:
| Observable | |||
query( String field , String/RegExp value , [Boolean anyMatch ], [Boolean caseSensitive ] )
:
MixedCollectionQuery the records by a specified property. Query the records by a specified property. Parameters:
| Store | |||
queryBy( Function fn , [Object scope ] )
:
MixedCollectionQuery the cached records in this Store using a filtering function. The specified function
will be called with each re... 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. Parameters:
| Store | |||
rejectChanges()
:
void Reject outstanding changes on all modified records. | Store | |||
relayEvents( Object o , Array events )
:
voidRelays selected events from the specified Observable as if the events were fired by this. Relays selected events from the specified Observable as if the events were fired by this. Parameters:
| Observable | |||
reload( [Object options ] )
:
voidReloads the Record cache from the configured Proxy using the configured Reader and
the options from the last load ope... Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load operation performed. Note: see the Important note in load. Parameters:
| Store | |||
remove( Ext.data.Record record )
:
voidRemove a Record from the Store and fires the remove event. Remove a Record from the Store and fires the remove event. Parameters:
| Store | |||
removeAll()
:
void Remove all Records from the Store and fires the clear event. Remove all Records from the Store and fires the clear event. Parameters:
| Store | |||
removeAt( Number index )
:
voidRemove a Record from the Store at the specified index. Fires the remove event. Remove a Record from the Store at the specified index. Fires the remove event. Parameters:
| Store | |||
removeListener( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler. Removes an event handler. Parameters:
| Observable | |||
resumeEvents()
:
void Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
event... Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
events fired during event suspension will be sent to any listeners now. Parameters:
| Observable | |||
save()
:
void Saves all pending changes to the store. If the commensurate Ext.data.Api.actions action is not configured, then
the ... Saves all pending changes to the store. If the commensurate Ext.data.Api.actions action is not configured, then
the configured url will be used.
change url --------------- -------------------- removed records Ext.data.Api.actions.destroy phantom records Ext.data.Api.actions.create modified records Ext.data.Api.actions.update Parameters:
| Store | |||
setBaseParam( String name , Mixed value )
:
voidSet the value for a property name in this store's baseParams. Usage:myStore.setBaseParam('foo', {bar:3}); Set the value for a property name in this store's baseParams. Usage:
Parameters:
| Store | |||
setDefaultSort( String fieldName , [String dir ] )
:
voidSets the default sort column and order to be used by the next load operation. Sets the default sort column and order to be used by the next load operation. Parameters:
| Store | |||
sort( String fieldName , [String dir ] )
:
voidSort the Records.
If remote sorting is used, the sort is performed on the server, and the cache is reloaded. If local... Sort the Records.
If remote sorting is used, the sort is performed on the server, and the cache is reloaded. If local
sorting is used, the cache is sorted internally. See also remoteSort and paramNames. Parameters:
| Store | |||
sum( String property , [Number start ], [Number end ] )
:
NumberSums 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. Parameters:
| Store | |||
suspendEvents( Boolean queueSuspended )
:
voidSuspend the firing of all events. (see resumeEvents) Suspend the firing of all events. (see resumeEvents) Parameters:
| Observable | |||
un( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler (shorthand for removeListener.) Removes an event handler (shorthand for removeListener.) Parameters:
| Observable |
Event | Defined By | |
---|---|---|
add :
( Store this , Ext.data.Record[] records , Number index )
Fires when Records have been added to the Store Fires when Records have been added to the Store Listeners will be called with the following arguments:
| Store | |
beforeload :
( Store this , Object options )
Fires before a request is made for a new data object. If the beforeload handler returns
false the load action will b... | Store | |
beforewrite :
( Ext.data.Store store , String action , Record/Array[Record] rs , Object options , Object arg )
Listeners will be called with the following arguments:
| Store | |
clear :
( Store this , Record[] The )
Fires when the data cache has been cleared. Fires when the data cache has been cleared. Listeners will be called with the following arguments:
| Store | |
datachanged :
( Store this )
Fires when the data cache has changed in a bulk manner (e.g., it has been sorted, filtered, etc.) and a
widget that i... Fires when the data cache has changed in a bulk manner (e.g., it has been sorted, filtered, etc.) and a
widget that is using this Store as a Record cache should refresh its view. Listeners will be called with the following arguments:
| Store | |
exception :
( misc misc )
Fires if an exception occurs in the Proxy during a remote request.
This event is relayed through the corresponding Ex... Fires if an exception occurs in the Proxy during a remote request. This event is relayed through the corresponding Ext.data.DataProxy. See Ext.data.DataProxy.exception for additional details. Listeners will be called with the following arguments:
| Store | |
load :
( Store this , Ext.data.Record[] records , Object options )
Fires after a new set of Records has been loaded. Fires after a new set of Records has been loaded. Listeners will be called with the following arguments:
| Store | |
loadexception :
( misc misc )
This event is deprecated in favor of the catch-all exception
event instead.
This event is relayed through the corresp... This event is deprecated in favor of the catch-all This event is relayed through the corresponding Ext.data.DataProxy. See Ext.data.DataProxy.loadexception for additional details. Listeners will be called with the following arguments:
| Store | |
metachange :
( Store this , Object meta )
Fires when this store's reader provides new metadata (fields). This is currently only supported for JsonReaders. Fires when this store's reader provides new metadata (fields). This is currently only supported for JsonReaders. Listeners will be called with the following arguments:
| Store | |
remove :
( Store this , Ext.data.Record record , Number index )
Fires when a Record has been removed from the Store Fires when a Record has been removed from the Store Listeners will be called with the following arguments:
| Store | |
update :
( Store this , Ext.data.Record record , String operation )
Fires when a Record has been updated Fires when a Record has been updated Listeners will be called with the following arguments:
| Store | |
write :
( Ext.data.Store store , String action , Object result , Ext.Direct.Transaction res , Record/Record[] rs )
Fires if the server returns 200 after an Ext.data.Api.actions CRUD action.
Success of the action is determined in the... Fires if the server returns 200 after an Ext.data.Api.actions CRUD action.
Success of the action is determined in the result['successProperty'] property (NOTE for RESTful stores,
a simple 20x response is sufficient for the actions "destroy" and "update". The "create" action should should return 200 along with a database pk).Listeners will be called with the following arguments:
| Store |