Properties Methods Events Config Options Direct Link
Observable
  Store

Class CQ.Ext.data.Store

Package:CQ.Ext.data
Class:Store
Subclasses:ArrayStore, DirectStore, GroupingStore, JsonStore, XmlStore, SlingStore
Extends:CQ.Ext.util.Observable
Clientlib:cq.widgets
xtype:store

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 CQ.Ext.data.ArrayStore({
    fields: ['fullname', 'first'],
    idIndex: 0 // id for each record will be the first element
});

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

// create a Record constructor:
var rt = CQ.Ext.data.Record.create([
    {name: 'fullname'},
    {name: 'first'}
]);
var myStore = new CQ.Ext.data.Store({
    // explicitly create reader
    reader: new CQ.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 Options Defined By

Public Properties

Property Defined By
  baseParams : Object
See the corresponding configuration option for a description of this property. To modify this property see setBaseParam.
Store
  fields : CQ.Ext.util.MixedCollection
A MixedCollection containing the defined Fields for the Records stored in this Store. Read-only.
Store
  isDestroyed : Boolean True
Store
  multiSort : Boolean True
Store
  multiSortInfo : Object
Object containing overall sort direction and an ordered array of sorter configs used when sorting on multiple fields
Store

Public Methods

Method Defined By

Public Events

Event Defined By