Properties Methods Events Config Options Direct Link
Observable
  Store

Class Ext.data.Store

Package:Ext.data
Defined In:Store.js
Class:Store
Subclasses:ArrayStore, DirectStore, GroupingStore, JsonStore, XmlStore
Extends:Observable

The Store class encapsulates a client side cache of Record objects which provide input data for Components such as the GridPanel, the ComboBox, or the DataView.

Retrieving Data

A Store object may access a data object using:

Reading Data

A Store object has no inherent knowledge of the format of the data object (it could be an Array, XML, or JSON). A Store object uses an appropriate configured implementation of a DataReader to create Record instances from the data object.

Store Types

There are several implementations of Store available which are customized for use with a specific DataReader implementation. Here is an example using an ArrayStore which implicitly creates a reader commensurate to an Array data object.

var myStore = new Ext.data.ArrayStore({
    fields: ['fullname', 'first'],
    idIndex: 0 // id for each record will be the first element
});

For custom implementations create a basic Ext.data.Store configured as needed:

// create a Record constructor:
var rt = Ext.data.Record.create([
    {name: 'fullname'},
    {name: 'first'}
]);
var myStore = new Ext.data.Store({
    // explicitly create reader
    reader: new Ext.data.ArrayReader(
        {
            idIndex: 0  // id for each record will be the first element
        },
        rt // recordType
    )
});

Load some data into store (note the data object is an array which corresponds to the reader):

var myData = [
    [1, 'Fred Flintstone', 'Fred'],  // note that id for the record is the first element
    [2, 'Barney Rubble', 'Barney']
];
myStore.loadData(myData);

Records are cached and made available through accessor functions. An example of adding a record to the store:

var defaultData = {
    fullname: 'Full Name',
    first: 'First Name'
};
var recId = 100; // provide unique id for the record
var r = new myStore.recordType(defaultData, ++recId); // create new record
myStore.insert(0, r); // insert a new record into the store (also see add)

Writing Data

And new in Ext version 3, use the new DataWriter to create an automated, Writable Store along with RESTful features.

Config Options

Config OptionsDefined By
 data : Array
An inline data object readable by the reader. Typically this option, or the url option will be specified.
Store
 proxy : Ext.data.DataProxy
The DataProxy object which provides access to a data object. See url.
Store

Public Properties

PropertyDefined By
 fields : Ext.util.MixedCollection
A MixedCollection containing the defined Fields for the Records stored in this Store. Read-only.
Store
 isDestroyed : Boolean True if the store has been destroyed already. Read only
Store
 multiSort : Boolean True if this store is currently sorted by more than one field/direction combination.
Store
 multiSortInfo : Object
Object containing overall sort direction and an ordered array of sorter configs used when sorting on multiple fields
Store

Public Methods

MethodDefined By

Public Events

EventDefined By