Package: | Ext.data |
Class: | Store |
Extends: | Observable |
Subclasses: | JsonStore, SimpleStore |
Defined In: | Store.js |
A Store object uses an implementation of Ext.data.DataProxy to access a data object unless you call loadData() directly and pass in your data. The Store object
has no knowledge of the format of the data returned by the Proxy.
A Store object uses its configured implementation of Ext.data.DataReader to create Ext.data.Record instances from the data object. These records are cached and made available through accessor functions.
Method | Defined By | |
---|---|---|
Store( Object config ) |
Store | |
Creates a new Store. | ||
add( Ext.data.Record[] records ) : void |
Store | |
Add Records to the Store and fires the add event. | ||
addEvents( Object object ) : void |
Observable | |
Used to define events on this Observable | ||
addListener( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this component | ||
clearFilter( Boolean suppressEvent ) : void |
Store | |
Revert to a view of the Record cache with no filtering applied. | ||
collect( String dataIndex , [Boolean allowNull ], [Boolean bypassFilter ] ) : Array |
Store | |
Collects unique values for a particular dataIndex from this store. | ||
commitChanges() : void | Store | |
Commit all Records with outstanding changes. To handle updates for changes, subscribe to the Store's "update" event, ... | ||
each( Function fn , [Object scope ] ) : void |
Store | |
Calls the specified function for each of the Records in the cache. | ||
filter( String field , String/RegExp value , Boolean anyMatch ) : void |
Store | |
Filter the records by a specified property. | ||
filterBy( Function fn , [Object scope ] ) : void |
Store | |
Filter by a function. The specified function will be called with each record in this data source. If the function ret... | ||
fireEvent( String eventName , Object... args ) : Boolean |
Observable | |
Fires the specified event with the passed parameters (minus the event name). | ||
getAt( Number index ) : Ext.data.Record |
Store | |
Get the Record at the specified index. | ||
getById( String id ) : Ext.data.Record |
Store | |
Get the Record with the specified id. | ||
getCount() : void | Store | |
Gets the number of cached records. If using paging, this may not be the total size of the dataset. If the data objec... | ||
getModifiedRecords() : Ext.data.Record[] | Store | |
Get all records modified since the last load, or since the last commit. | ||
getRange( [Number startIndex ], [Number endIndex ] ) : Ext.data.Record[] |
Store | |
Returns a range of Records between specified indices. | ||
getSortState() : void | Store | |
Returns the sort state of the Store as an object with two properties: field {String} The name of the field by which t... | ||
getTotalCount() : void | Store | |
Gets the total number of records in the dataset. If using paging, for this to be accurate, the data object used by t... | ||
hasListener( String eventName ) : Boolean |
Observable | |
Checks to see if this object has any listeners for a specified event | ||
indexOf( Ext.data.Record record ) : Number |
Store | |
Get the index within the cache of the passed Record. | ||
indexOfId( String id ) : Number |
Store | |
Get the index within the cache of the Record with the passed id. | ||
insert( Number index , Ext.data.Record[] records ) : void |
Store | |
Inserts Records to the Store at the given index and fires the add event. | ||
load( Object options ) : void |
Store | |
Loads the Record cache from the configured Proxy using the configured Reader. If using remote paging, then the first... | ||
loadData( Object data , [Boolean append ] ) : void |
Store | |
Loads data from a passed data block. A Reader which understands the format of the data must have been configured in t... | ||
on( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this element (shorthand for addListener) | ||
purgeListeners() : void | Observable | |
Removes all listeners for this object | ||
query( String field , String/RegExp value , Boolean anyMatch ) : MixedCollection |
Store | |
Query the records by a specified property. | ||
queryBy( Function fn , [Object scope ] ) : MixedCollection |
Store | |
Query by a function. The specified function will be called with each record in this data source. If the function retu... | ||
rejectChanges() : void | Store | |
Cancel outstanding changes on all changed records. | ||
reload( [Object options ] ) : void |
Store | |
Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load ope... | ||
remove( Ext.data.Record record ) : void |
Store | |
Remove a Record from the Store and fires the remove event. | ||
removeAll() : void | Store | |
Remove all Records from the Store and fires the clear event. | ||
removeListener( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener | ||
setDefaultSort( String fieldName , [String dir ] ) : void |
Store | |
Sets the default sort column and order to be used by the next load operation. | ||
sort( String fieldName , [String dir ] ) : void |
Store | |
Sort the Records. If remote sorting is used, the sort is performed on the server, and the cache is reloaded. If local... | ||
sum( String property , Number start , Number end ) : Number |
Store | |
Sums the value of property for each record between start and end and returns the result. | ||
un( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener (shorthand for removeListener) |
Event | Defined By | |
---|---|---|
add : ( Store this , Ext.data.Record[] records , Number index ) |
Store | |
Fires when Records have been added to the Store | ||
beforeload : ( Store this , Object options ) |
Store | |
Fires before a request is made for a new data object. If the beforeload handler returns false the load action will b... | ||
clear : ( Store this ) |
Store | |
Fires when the data cache has been cleared. | ||
datachanged : ( Store this ) |
Store | |
Fires when the data cache has changed, and a widget which is using this Store as a Record cache should refresh its view. | ||
load : ( Store this , Ext.data.Record[] records , Object options ) |
Store | |
Fires after a new set of Records has been loaded. | ||
loadexception : () | Store | |
Fires if an exception occurs in the Proxy during loading. Called with the signature of the Proxy's "loadexception" ev... | ||
metachange : ( Store this , Object meta ) |
Store | |
Fires when this stores reader provides new meta data (fields). This is currently only support for JsonReaders. | ||
remove : ( Store this , Ext.data.Record record , Number index ) |
Store | |
Fires when Records have been removed from the Store | ||
update : ( Store this , Ext.data.Record record , String operation ) |
Store | |
Fires when Records have been updated |
Config Options | Defined By | |
---|---|---|
baseParams : Object | Store | |
An object containing properties which are to be sent as parameters on any HTTP request | ||
data : Array | Store | |
Inline data to be loaded when the store is initialized. | ||
proxy : Ext.data.DataProxy | Store | |
The Proxy object which provides access to a data object. | ||
pruneModifiedRecords : boolean | Store | |
True to clear all modified record information each time the store is loaded or when a record is removed. (defaults to... | ||
reader : Ext.data.Reader | Store | |
The Reader object which processes the data object and returns an Array of Ext.data.record objects which are cached ke... | ||
remoteSort : boolean | Store | |
True if sorting is to be handled by requesting the Proxy to provide a refreshed version of the data object in sorted ... | ||
sortInfo : Object | Store | |
A config object in the format: {field: "fieldName", direction: "ASC|DESC"} |
public function Store( Object config
)
config
: Objectpublic function add( Ext.data.Record[] records
)
records
: Ext.data.Record[]void
public function addEvents( Object object
)
object
: Objectvoid
public function addListener( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
Combining Options
Using the options argument, it is possible to combine different types of listeners:
A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
el.on('click', this.onClick, this, {
single: true,
delay: 100,
forumId: 4
});
Attaching multiple handlers in 1 call
The method also allows for a single argument to be passed which is a config object containing properties
which specify multiple handlers.
el.on({
'click': {
fn: this.onClick,
scope: this,
delay: 100
},
'mouseover': {
fn: this.onMouseOver,
scope: this
},
'mouseout': {
fn: this.onMouseOut,
scope: this
}
});
Or a shorthand syntax which passes the same scope object to all handlers:
el.on({
'click': this.onClick,
'mouseover': this.onMouseOver,
'mouseout': this.onMouseOut,
scope: this
});
void
public function clearFilter( Boolean suppressEvent
)
suppressEvent
: Booleanvoid
public function collect( String dataIndex
, [Boolean allowNull
], [Boolean bypassFilter
] )
dataIndex
: StringallowNull
: BooleanbypassFilter
: BooleanArray
public function commitChanges()
void
public function each( Function fn
, [Object scope
] )
fn
: Functionscope
: Objectvoid
public function filter( String field
, String/RegExp value
, Boolean anyMatch
)
field
: Stringvalue
: String/RegExpanyMatch
: Booleanvoid
public function filterBy( Function fn
, [Object scope
] )
fn
: Functionscope
: Objectvoid
public function fireEvent( String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function getAt( Number index
)
index
: NumberExt.data.Record
public function getById( String id
)
id
: StringExt.data.Record
public function getCount()
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 data set size
void
public function getModifiedRecords()
Ext.data.Record[]
public function getRange( [Number startIndex
], [Number endIndex
] )
startIndex
: NumberendIndex
: NumberExt.data.Record[]
public function getSortState()
field {String} The name of the field by which the Records are sorted
direction {String} The sort order, "ASC" or "DESC"
void
public function getTotalCount()
If using paging, for this to be accurate, the data object used by the Reader must contain the dataset size
void
public function hasListener( String eventName
)
eventName
: StringBoolean
public function indexOf( Ext.data.Record record
)
record
: Ext.data.RecordNumber
public function indexOfId( String id
)
id
: StringNumber
public function insert( Number index
, Ext.data.Record[] records
)
index
: Numberrecords
: Ext.data.Record[]void
public function load( Object options
)
If using remote paging, then the first load call must specify the start and limit properties in the options.params property to establish the initial position within the dataset, and the number of Records to cache on each read from the Proxy.
It is important to note that for remote data sources, loading is asynchronous, and this call will return before the new data has been loaded. Perform any post-processing in a callback function, or in a "load" event handler.
options
: Objectvoid
public function loadData( Object data
, [Boolean append
] )
data
: Objectappend
: Booleanvoid
public function on( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Objectvoid
public function purgeListeners()
void
public function query( String field
, String/RegExp value
, Boolean anyMatch
)
field
: Stringvalue
: String/RegExpanyMatch
: BooleanMixedCollection
public function queryBy( Function fn
, [Object scope
] )
fn
: Functionscope
: ObjectMixedCollection
public function rejectChanges()
void
public function reload( [Object options
] )
options
: Objectvoid
public function remove( Ext.data.Record record
)
record
: Ext.data.Recordvoid
public function removeAll()
void
public function removeListener( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function setDefaultSort( String fieldName
, [String dir
] )
fieldName
: Stringdir
: Stringvoid
public function sort( String fieldName
, [String dir
] )
fieldName
: Stringdir
: Stringvoid
public function sum( String property
, Number start
, Number end
)
property
: Stringstart
: Numberend
: NumberNumber
public function un( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public event add
this
: Storerecords
: Ext.data.Record[]index
: Numberpublic event beforeload
this
: Storeoptions
: Objectpublic event clear
this
: Storepublic event datachanged
this
: Storepublic event load
this
: Storerecords
: Ext.data.Record[]options
: Objectpublic event loadexception
public event metachange
this
: Storemeta
: Objectpublic event remove
this
: Storerecord
: Ext.data.Recordindex
: Numberpublic event update
this
: Storerecord
: Ext.data.Recordoperation
: StringExt.data.Record.EDIT
Ext.data.Record.REJECT
Ext.data.Record.COMMIT
baseParams : Object
data : Array
proxy : Ext.data.DataProxy
pruneModifiedRecords : boolean
reader : Ext.data.Reader
remoteSort : boolean
sortInfo : Object