Ext JS 3.4.0 Sencha Docs

Ext.data.Store

Hierarchy

Ext.util.Observable
Ext.data.Store

Subclasses

Files

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.

Available since: 1.1.0

Defined By

Config options

Ext.data.Store
view source
: Boolean
true to destroy the store when the component the store is bound to is destroyed (defaults to false). ...

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.

Defaults to: false

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Boolean/Object
If data is not specified, and if autoLoad is true or an Object, this store's load method is automatically called afte...

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.

Available since: 2.3.0

Ext.data.Store
view source
: Boolean
Defaults to true causing the store to automatically save records to the server when a record is modified (ie: becomes...

Defaults to true causing the store to automatically save records to the server when a record is modified (ie: becomes 'dirty'). Specify false to manually call save to send all modifiedRecords to the server.


Note: each CRUD action will be sent as a separate request.

Defaults to: true

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Object
An object containing properties which are to be sent as parameters for every HTTP request. ...

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: baseParams may be superseded by any params specified in a load request, see load for more details.

This property may be modified after creation using the setBaseParam method.

Available since: 1.1.0

Ext.data.Store
view source
: Boolean
Defaults to true (unless restful:true). ...

Defaults to true (unless restful:true). Multiple requests for each CRUD action (CREATE, READ, UPDATE and DESTROY) will be combined and sent as one transaction. Only applies when autoSave is set to false.


If Store is RESTful, the DataProxy is also RESTful, and a unique transaction is

generated for each record.

Defaults to: true

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Array
An inline data object readable by the reader. ...

An inline data object readable by the reader. Typically this option, or the url option will be specified.

Available since: 1.1.0

Ext.data.Store
view source
: Object
Provides the default values for the paramNames property. ...

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.

Defaults to: {start: 'start', limit: 'limit', sort: 'sort', dir: 'dir'}

Available since: Ext JS 3.4.0

(optional) A config object containing one or more event handlers to be added to this object during initialization. ...

(optional)

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 click event passing the node clicked on. To access DOM events directly from a Component's HTMLElement, listeners must be added to the Element after the Component has been rendered. A plugin can simplify this step:

// Plugin is configured with a listeners config object.
// The Component is appended to the argument list of all handler functions.
Ext.DomObserver = Ext.extend(Object, {
    constructor: function(config) {
        this.listeners = config.listeners ? config.listeners : config;
    },

    // Component passes itself into plugin's init method
    init: function(c) {
        var p, l = this.listeners;
        for (p in l) {
            if (Ext.isFunction(l[p])) {
                l[p] = this.createHandler(l[p], c);
            } else {
                l[p].fn = this.createHandler(l[p].fn, c);
            }
        }

        // Add the listeners to the Element immediately following the render call
        c.render = c.render.createSequence(function() {
            var e = c.getEl();
            if (e) {
                e.on(l);
            }
        });
    },

    createHandler: function(fn, c) {
        return function(e) {
            fn.call(this, e, c);
        };
    }
});

var combo = new Ext.form.ComboBox({

    // Collapse combo when its element is clicked on
    plugins: [ new Ext.DomObserver({
        click: function(evt, comp) {
            comp.collapse();
        }
    })],
    store: myStore,
    typeAhead: true,
    mode: 'local',
    triggerAction: 'all'
});

Available since: 1.1.0

Ext.data.Store
view source
: 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:

{
    start : 'start',  // The parameter name which specifies the start row
    limit : 'limit',  // The parameter name which specifies number of rows to return
    sort : 'sort',    // The parameter name which specifies the column to sort on
    dir : 'dir'       // The parameter name which specifies the sort direction
}

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.

Available since: Ext JS 3.4.0

The DataProxy object which provides access to a data object. ...

The DataProxy object which provides access to a data object. See url.

Available since: 1.1.0

Ext.data.Store
view source
: 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.

Defaults to: false

Available since: 1.1.0

The Reader object which processes the data object and returns an Array of Ext.data.Record objects which are cached ke...

The Reader object which processes the data object and returns an Array of Ext.data.Record objects which are cached keyed by their id property.

Available since: 1.1.0

Ext.data.Store
view source
: 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:

  • sort : String

    The name (as specified in the Record's Field definition) of the field to sort on.

  • dir : String

    The direction of the sort, 'ASC' or 'DESC' (case-sensitive).

Defaults to: false

Available since: 1.1.0

Ext.data.Store
view source
: Boolean
Defaults to false. ...

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 restful:true batch will internally be set to false.

Defaults to: false

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Object
A config object to specify the sort order in the request of a Store's load operation. ...

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:

sortInfo: {
    field: 'fieldName',
    direction: 'ASC' // or 'DESC' (case sensitive for local sorting)
}

Available since: 1.1.0

Ext.data.Store
view source
: String
If passed, the id to use to register with the StoreMgr. ...

If passed, the id to use to register with the StoreMgr.

Note: if a (deprecated) id is specified it will supersede the storeId assignment.

Available since: 2.3.0

Ext.data.Store
view source
: String
If a proxy is not specified the url will be used to implicitly configure a HttpProxy if an url is specified. ...

If a proxy is not specified the url will be used to implicitly configure a HttpProxy if an url is specified. Typically this option, or the data option will be specified.

Available since: 2.3.0

The Writer object which processes a record object for being written to the server-side database. ...

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:

var writer = new Ext.data.JsonWriter({
    encode: true,
    writeAllFields: true // write all fields, not just those that changed
});

// Typical Store collecting the Proxy, Reader and Writer together.
var store = new Ext.data.Store({
    storeId: 'user',
    root: 'records',
    proxy: proxy,
    reader: reader,
    writer: writer,     // <-- plug a DataWriter into the store just as you would a Reader
    paramsAsHash: true,
    autoSave: false    // <-- false to delay executing create, update, destroy requests
                        //     until specifically told to do so.
});

Available since: Ext JS 3.4.0

Defined By

Properties

Ext.data.Store
view source
: Object
See the corresponding configuration option for a description of this property. ...

See the corresponding configuration option for a description of this property. To modify this property see setBaseParam.

Available since: 2.3.0

Ext.data.Store
view source
: Stringprivate
private ...

private

Defaults to: '_ext_batch_'

Available since: Ext JS 3.4.0

A MixedCollection containing the defined Fields for the Records stored in this Store. ...

A MixedCollection containing the defined Fields for the Records stored in this Store. Read-only.

Available since: 2.3.0

Ext.data.Store
view source
hasMultiSort : Boolean

True if this store is currently sorted by more than one field/direction combination.

True if this store is currently sorted by more than one field/direction combination.

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Boolean
True if the store has been destroyed already. ...

True if the store has been destroyed already. Read only

Available since: Ext JS 3.4.0

Ext.data.Store
view source
: Object
Contains the last options object used as the parameter to the load method. ...

Contains the last options object used as the parameter to the load method. See load for the details of what this may contain. This may be useful for accessing any params which were used to load the current Record cache.

Available since: 2.3.0

Ext.data.Store
view source
multiSortInfo : Object

Object containing overall sort direction and an ordered array of sorter configs used when sorting on multiple fields

Object containing overall sort direction and an ordered array of sorter configs used when sorting on multiple fields

Available since: Ext JS 3.4.0

The Record constructor as supplied to (or created by) the Reader. ...

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:

    // create the data store
    var store = new Ext.data.ArrayStore({
        autoDestroy: true,
        fields: [
           {name: 'company'},
           {name: 'price', type: 'float'},
           {name: 'change', type: 'float'},
           {name: 'pctChange', type: 'float'},
           {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
        ]
    });
    store.loadData(myData);

    // create the Grid
    var grid = new Ext.grid.EditorGridPanel({
        store: store,
        colModel: new Ext.grid.ColumnModel({
            columns: [
                {id:'company', header: 'Company', width: 160, dataIndex: 'company'},
                {header: 'Price', renderer: 'usMoney', dataIndex: 'price'},
                {header: 'Change', renderer: change, dataIndex: 'change'},
                {header: '% Change', renderer: pctChange, dataIndex: 'pctChange'},
                {header: 'Last Updated', width: 85,
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    dataIndex: 'lastChange'}
            ],
            defaults: {
                sortable: true,
                width: 75
            }
        }),
        autoExpandColumn: 'company', // match the id specified in the column model
        height:350,
        width:600,
        title:'Array Grid',
        tbar: [{
            text: 'Add Record',
            handler : function(){
                var defaultData = {
                    change: 0,
                    company: 'New Company',
                    lastChange: (new Date()).clearTime(),
                    pctChange: 0,
                    price: 10
                };
                var recId = 3; // provide unique id
                var p = new store.recordType(defaultData, recId); // create new record
                grid.stopEditing();
                store.insert(0, p); // insert a new record into the store (also see add)
                grid.startEditing(0, 0);
            }
        }]
    });

Available since: 2.3.0

Defined By

Methods

Ext.data.Store
view source
new( config ) : Ext.data.Store
Creates a new Store. ...

Creates a new Store.

Available since: 1.1.0

Parameters

  • config : Object

    A config object containing the objects needed for the Store to access data, and read the data into Records.

Returns

Ext.data.Store
view source
( records )
Add Records to the Store and fires the add event. ...

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.

Available since: 1.1.0

Parameters

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.

  • Optional : string

    . Event name if multiple event names are being passed as separate parameters. Usage:

    this.addEvents('storeloaded', 'storecleared');
    
( eventName, handler, [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.

  • handler : Function

    The method the event invokes.

  • 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. properties. This 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.

    Combining Options
    Using the options argument, it is possible to combine different types of listeners:

    A delayed, one-time listener.

    myDataView.on('click', this.onClick, 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 handlers.

    myGridPanel.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:

    myGridPanel.on({
    'click' : this.onClick,
    'mouseover' : this.onMouseOver,
    'mouseout' : this.onMouseOut,
     scope: this
    });
Ext.data.Store
view source
( record )
(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.

Available since: 2.3.0

Parameters

Ext.data.Store
view source
( batch )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • batch : Object
Ext.data.Store
view source
( record )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • record : Object
Ext.data.Store
view source
( record )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • record : Object
Ext.data.Store
view source
( record )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • record : Object
Ext.data.Store
view source
( )private
Invokes sortData if we have sortInfo to sort on and are not sorting remotely ...

Invokes sortData if we have sortInfo to sort on and are not sorting remotely

Available since: Ext JS 3.4.0

Ext.data.Store
view source
( config ) : Ext.data.DataWriterprivate
builds a DataWriter instance when Store constructor is provided with a writer config-object instead of an instace. ...

builds a DataWriter instance when Store constructor is provided with a writer config-object instead of an instace.

Available since: Ext JS 3.4.0

Parameters

  • config : Object

    Writer configuration

Returns

Ext.data.Store
view source
( )private
private ...

private

Available since: Ext JS 3.4.0

Ext.data.Store
view source
( 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.

Ext.data.Store
view source
( rs )private
Clears records from modified array after an exception event. ...

Clears records from modified array after an exception event. NOTE: records are left marked dirty. Do we want to commit them even though they were not updated/realized? TODO remove this method?

Available since: Ext JS 3.4.0

Parameters

  • rs : Object
Ext.data.Store
view source
( dataIndex, [allowNull], [bypassFilter] ) : Array
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

  • Array

    An array of the unique values

Ext.data.Store
view source
( )
Commit all Records with outstanding changes. ...

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.

Available since: 1.1.0

Ext.data.Store
view source
( action, rs, batch )private
callback-handler for remote CRUD actions Do not override -- override loadRecords, onCreateRecords, onDestroyRecords a...

callback-handler for remote CRUD actions Do not override -- override loadRecords, onCreateRecords, onDestroyRecords and onUpdateRecords instead.

Available since: Ext JS 3.4.0

Parameters

  • action : Object
  • rs : Object
  • batch : Object
Ext.data.Store
view source
( property, value, anyMatch, caseSensitive, exactMatch )private
Returns 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: Ext JS 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

    True if we don't care if the filter value is not the full value (defaults to false)

  • caseSensitive : Boolean

    True to create a case-sensitive regex (defaults to false)

  • exactMatch : Boolean

    True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.

Ext.data.Store
view source
( filters ) : Functionprivate
Given an array of filter functions (each with optional scope), constructs and returns a single function that returns ...

Given an array of filter functions (each with optional scope), constructs and returns a single function that returns the result of all of the filters ANDed together

Available since: Ext JS 3.4.0

Parameters

  • filters : Array

    The array of filter objects (each object should contain an 'fn' and optional scope)

Returns

Ext.data.Store
view source
( store, records, index )private
Should not be used directly. ...

Should not be used directly. Store#add will call this automatically if a Writer is set

Available since: Ext JS 3.4.0

Parameters

  • store : Object
  • records : Object
  • index : Object
Ext.data.Store
view source
( field, direction ) : Functionprivate
Creates and returns a function which sorts an array by the given field and direction ...

Creates and returns a function which sorts an array by the given field and direction

Available since: Ext JS 3.4.0

Parameters

  • field : String

    The field to create the sorter for

  • direction : String

    The direction to sort by (defaults to "ASC")

Returns

  • Function

    A function which sorts by the field/direction combination provided

Ext.data.Store
view source
( )
Destroys the store. ...

Destroys the store.

Available since: Ext JS 3.4.0

Ext.data.Store
view source
( store, record, index )private
Destroys a Record. ...

Destroys a Record. Should not be used directly. It's called by Store#remove if a Writer is set.

Available since: Ext JS 3.4.0

Parameters

Ext.data.Store
view source
( action, rs, batch )private
private. ...

private. Simply wraps call to Store#execute in try/catch. Defers to Store#handleException on error. Loops if batch: false

Available since: Ext JS 3.4.0

Parameters

  • action : Object
  • rs : Object
  • batch : Object
Ext.data.Store
view source
( rec )private
Update a record within the store with a new reference ...

Update a record within the store with a new reference

Available since: Ext JS 3.4.0

Parameters

  • rec : Object
Ext.data.Store
view source
( 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

  • fn : Function

    The function to call. The Record is passed as the first parameter. Returning false aborts and exits the iteration.

  • scope : Object (optional)

    The scope (this reference) in which the function is executed. Defaults to the current Record in the iteration.

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, {
    //  Add functionality to Field's initComponent to enable the change event to bubble
    initComponent : Ext.form.Field.prototype.initComponent.createSequence(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: Ext JS 3.4.0

Parameters

  • events : String/Array

    The event name to bubble, or an Array of event names.

Ext.data.Store
view source
( action, rs, options )private
This method should generally not be used directly. ...

This method should generally not be used directly. This method is called internally by load, or if a Writer is set will be called automatically when add, remove, or update events fire.

Available since: Ext JS 3.4.0

Parameters

  • action : String

    Action name ('read', 'create', 'update', or 'destroy')

  • rs : Record/Record[]
  • options : Object

Throws

  • Object

    Error

Ext.data.Store
view source
( field, value, [anyMatch], [caseSensitive], [exactMatch] )
Filter the records by a specified property. ...

Filter the records by a specified property. Alternatively, pass an array of filter options to filter by more than one property. Single filter example: store.filter('name', 'Ed', true, true); //finds all records containing the substring 'Ed' Multiple filter example:

store.filter([
  {
    property     : 'name',
    value        : 'Ed',
    anyMatch     : true, //optional, defaults to true
    caseSensitive: true  //optional, defaults to true
  },

  //filter functions can also be passed
  {
    fn   : function(record) {
      return record.get('age') == 24
    },
    scope: this
  }
]);

Available since: 1.1.0

Parameters

  • field : String|Array

    A field on your records, or an array containing multiple filter options

  • value : String/RegExp

    Either a string that the field should begin with, or a RegExp to test against the field.

  • anyMatch : Boolean (optional)

    true to match any part 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. Ignored if anyMatch is true.

Ext.data.Store
view source
( 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:

  • scope : Object (optional)

    The scope (this reference) in which the function is executed. Defaults to this Store.

Ext.data.Store
view source
( fieldName, value, [startIndex], [anyMatch], [caseSensitive] ) : Number
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

Returns

  • Number

    The matched index or -1

Ext.data.Store
view source
( fn, [scope], [startIndex] ) : Number
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:

  • 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

Ext.data.Store
view source
( fieldName, value, [startIndex] ) : Number
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: Ext JS 3.4.0

Parameters

  • fieldName : String

    The name of the Record field to test.

  • value : Mixed

    The value to match the field against.

  • startIndex : Number (optional)

    The index to start searching at

Returns

  • Number

    The matched index or -1

Ext.data.Store
view source
( record )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • record : Object
( eventName, args ) : Boolean
Fires the specified event with the passed parameters (minus the event name). ...

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.

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.

Ext.data.Store
view source
( index ) : Ext.data.Record
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.Record

    The Record at the passed index. Returns undefined if not found.

Ext.data.Store
view source
( id ) : Ext.data.Record
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.Record

    The Record with the passed id. Returns undefined if not found.

Ext.data.Store
view source
( ) : Number
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.

Gets all records modified since the last commit. ...

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..

Available since: 1.1.0

Returns

Ext.data.Store
view source
( [startIndex], [endIndex] ) : Ext.data.Record[]
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.Store
view source
( ) : Object
Returns an object describing the current sort state of this Store. ...

Returns an object describing the current sort state of this Store.

Available since: 1.1.0

Returns

  • Object

    The sort state of the Store. An object with two properties:

    • field : String

      The name of the field by which the Records are sorted.

    • direction : String

      The sort order, 'ASC' or 'DESC' (case-sensitive).

    See sortInfo for additional details.

Ext.data.Store
view source
( ) : Number
Gets the total number of records in the dataset as returned by the server. ...

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.

Available since: 1.1.0

Returns

  • Number

    The number of Records as specified in the data object passed to the Reader by the Proxy.

    Note: this value is not updated when changing the contents of the Store locally.

Ext.data.Store
view source
( e )private
protected handleException. ...

protected handleException. Possibly temporary until Ext framework has an exception-handler.

Available since: Ext JS 3.4.0

Parameters

  • e : Object
Checks 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

Available since: 1.1.0

Parameters

  • eventName : String

    The name of the event to check for

Returns

  • Boolean

    True if the event is being listened for, else false

Ext.data.Store
view source
( record ) : Number
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

Returns

  • Number

    The index of the passed Record. Returns -1 if not found.

Ext.data.Store
view source
( id ) : Number
Get 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.

Available since: 1.1.0

Parameters

  • id : String

    The id of the Record to find.

Returns

  • Number

    The index of the Record. Returns -1 if not found.

Ext.data.Store
view source
( index, records )
Inserts Records into the Store at the given index and fires the add event. ...

Inserts Records into the Store at the given index and fires the add event. See also add and addSorted.

Available since: 1.1.0

Parameters

Ext.data.Store
view source
( ) : Boolean
Returns true if this store is currently filtered ...

Returns true if this store is currently filtered

Available since: 2.3.0

Returns

  • Boolean
Ext.data.Store
view source
( options ) : Boolean
Loads the Record cache from the configured proxy using the configured reader. ...

Loads the Record cache from the configured proxy using the configured reader.


Notes:

  • Important: loading is asynchronous! This call will return before the new data has been loaded. To perform any post-processing where information from the load call is required, specify the callback function to be called, or use a a 'load' event handler.
  • If using remote paging, 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.
  • If using remote sorting, the configured sortInfo will be automatically included with the posted parameters according to the specified paramNames.

Available since: 1.1.0

Parameters

  • options : Object

    An object containing properties which control loading options:

    • params :Object

      An object containing properties to pass as HTTP parameters to a remote data source. Note: params will override any baseParams of the same name.

    Parameters are encoded as standard HTTP parameters using Ext.urlEncode.

  • callback : Function

    A function to be called after the Records have been loaded. The callback is called after the load event is fired, and is passed the following arguments:

    • r : Ext.data.Record[] An Array of Records loaded.
    • options : Options object from the load call.
    • success : Boolean success indicator.

  • scope : Object

    Scope with which to call the callback (defaults to the Store object)

  • add : Boolean

    Indicator to append loaded records rather than replace the current cache. Note: see note for loadData

Returns

  • Boolean

    If the developer provided beforeload event handler returns false, the load call will abort and will return false; otherwise will return true.

Ext.data.Store
view source
( data, [append] )
Loads data from a passed data block and fires the load event. ...

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.

Available since: 1.1.0

Parameters

  • data : Object

    The data block from which to read the Records. The format of the data expected is dependent on the type of Reader that is configured and should correspond to that Reader's Ext.data.Reader.readRecords parameter.

  • append : Boolean (optional)

    true to append the new Records rather the default to replace the existing cache. Note: that Records in a Store are keyed by their id, so added Records with ids which are already present in the Store will replace existing Records. Only Records with new, unique ids will be added.

Ext.data.Store
view source
( o, options, success )private
private Called as a callback by the Reader during a load operation. ...

private Called as a callback by the Reader during a load operation.

Available since: Ext JS 3.4.0

Parameters

  • o : Object
  • options : Object
  • success : Object
Ext.data.Store
view source
( sorters, direction )
Sorts the contents of this store by multiple field/direction sorters. ...

Sorts the contents of this store by multiple field/direction sorters. This is called internally by sort and would not usually be called manually. Multi sorting only currently applies to local datasets - multiple sort data is not currently sent to a proxy if remoteSort is used.

Available since: Ext JS 3.4.0

Parameters

  • sorters : Array

    Array of sorter objects (field and direction)

  • direction : String

    Overall direction to sort the ordered results by (defaults to "ASC")

( eventName, handler, [scope], [options] )
Appends an event handler to this object (shorthand for addListener.) ...

Appends an event handler to this object (shorthand for addListener.)

Available since: 1.1.0

Parameters

  • eventName : String

    The type of event to listen for

  • handler : Function

    The method the event invokes

  • 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.

Ext.data.Store
view source
( store, records )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • store : Object
  • records : Object
Ext.data.Store
view source
( success, rs, data )privateprotected
onCreateRecord proxy callback for create action ...

onCreateRecord proxy callback for create action

Available since: Ext JS 3.4.0

Parameters

  • success : Object
  • rs : Object
  • data : Object
Ext.data.Store
view source
( success, rs, data )privateprotected
onDestroyRecords proxy callback for destroy action ...

onDestroyRecords proxy callback for destroy action

Available since: Ext JS 3.4.0

Parameters

  • success : Object
  • rs : Object
  • data : Object
Ext.data.Store
view source
( meta )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • meta : Object
Ext.data.Store
view source
( success, rs, data )privateprotected
, onUpdateRecords proxy callback for update action ...

, onUpdateRecords proxy callback for update action

Available since: Ext JS 3.4.0

Parameters

  • success : Object
  • rs : Object
  • data : Object
Removes all listeners for this object ...

Removes all listeners for this object

Available since: 1.1.0

Ext.data.Store
view source
( field, value, [anyMatch], [caseSensitive] ) : MixedCollection
Query the records by a specified property. ...

Query the records by a specified property.

Available since: 1.1.0

Parameters

  • field : String

    A field on your records

  • value : String/RegExp

    Either a string that the field should begin with, or a RegExp to test against the field.

  • anyMatch : Boolean (optional)

    True to match any part not just the beginning

  • caseSensitive : Boolean (optional)

    True for case sensitive comparison

Returns

Ext.data.Store
view source
( fn, [scope] ) : MixedCollection
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:

  • scope : Object (optional)

    The scope (this reference) in which the function is executed. Defaults to this Store.

Returns

Ext.data.Store
view source
( record )private
remap record ids in MixedCollection after records have been realized. ...

remap record ids in MixedCollection after records have been realized. @see Store#onCreateRecords, @see DataReader#realize

Available since: Ext JS 3.4.0

Parameters

  • record : Object
Ext.data.Store
view source
( )
Reject outstanding changes on all modified records. ...

Reject outstanding changes on all modified records.

Available since: 1.1.0

Relays 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.

Available since: 2.3.0

Parameters

  • o : Object

    The Observable whose events this object is to relay.

  • events : Array

    Array of event names to relay.

Ext.data.Store
view source
( options )
Reloads 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.

Available since: 1.1.0

Parameters

  • options : Object

    (optional) An Object containing loading options which may override the options used in the last load operation. See load for details (defaults to null, in which case the lastOptions are used).


    To add new params to the existing params:

    lastOptions = myStore.lastOptions;
    Ext.apply(lastOptions.params, {
        myNewParam: true
    });
    myStore.reload(lastOptions);
    
Ext.data.Store
view source
( record )
Remove Records from the Store and fires the remove event. ...

Remove Records from the Store and fires the remove event.

Available since: 1.1.0

Parameters

Ext.data.Store
view source
( silent )
Remove all Records from the Store and fires the clear event. ...

Remove all Records from the Store and fires the clear event.

Available since: 1.1.0

Parameters

  • silent : Boolean

    [false] Defaults to false. Set true to not fire clear event.

Ext.data.Store
view source
( index )
Remove a Record from the Store at the specified index. ...

Remove a Record from the Store at the specified index. Fires the remove event.

Available since: 2.3.0

Parameters

  • index : Number

    The index of the record to remove.

Ext.data.Store
view source
( batch, action, data )private
...

Available since: Ext JS 3.4.0

Parameters

  • batch : Object
  • action : Object
  • data : Object
( eventName, handler, [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.

  • handler : 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.

Resume firing events. ...

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.

Available since: 2.3.0

Ext.data.Store
view source
( ) : Number
Saves all pending changes to the store. ...

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

@TODO: Create extensions of Error class and send associated Record with thrown exceptions. e.g.: Ext.data.DataReader.Error or Ext.data.Error or Ext.data.DataProxy.Error, etc.

Available since: Ext JS 3.4.0

Returns

  • Number

    batch Returns a number to uniquely identify the "batch" of saves occurring. -1 will be returned if there are no items to save or the save was cancelled.

Ext.data.Store
view source
( name, value )
Set the value for a property name in this store's baseParams. ...

Set the value for a property name in this store's baseParams. Usage:

myStore.setBaseParam('foo', {bar:3});

Available since: Ext JS 3.4.0

Parameters

  • name : String

    Name of the property to assign

  • value : Mixed

    Value to assign the named property

Ext.data.Store
view source
( fieldName, [dir] )
Sets 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.

Available since: 1.1.0

Parameters

  • fieldName : String

    The name of the field to sort by.

  • dir : String (optional)

    The sort order, 'ASC' or 'DESC' (case-sensitive, defaults to 'ASC')

Ext.data.Store
view source
( fieldName, [dir] )
Sorts the store contents by a single field and direction. ...

Sorts the store contents by a single field and direction. This is called internally by sort and would not usually be called manually

Available since: Ext JS 3.4.0

Parameters

  • fieldName : String

    The name of the field to sort by.

  • dir : String (optional)

    The sort order, 'ASC' or 'DESC' (case-sensitive, defaults to 'ASC')

Ext.data.Store
view source
( fieldName, [dir] )
Sort the Records. ...

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. This function accepts two call signatures - pass in a field name as the first argument to sort on a single field, or pass in an array of sort configuration objects to sort by multiple fields. Single sort example: store.sort('name', 'ASC'); Multi sort example: store.sort([ {

field    : 'name',
direction: 'ASC'

}, {

field    : 'salary',
direction: 'DESC'

} ], 'ASC'); In this second form, the sort configs are applied in order, with later sorters sorting within earlier sorters' results. For example, if two records with the same name are present they will also be sorted by salary if given the sort configs above. Any number of sort configs can be added.

Available since: 1.1.0

Parameters

  • fieldName : String/Array

    The name of the field to sort by, or an array of ordered sort configs

  • dir : String (optional)

    The sort order, 'ASC' or 'DESC' (case-sensitive, defaults to 'ASC')

Ext.data.Store
view source
( )private
Performs the actual sorting of data. ...

Performs the actual sorting of data. This checks to see if we currently have a multi sort or not. It applies each sorter field/direction pair in turn by building an OR'ed master sorting function and running it against the full dataset

Available since: Ext JS 3.4.0

Ext.data.Store
view source
( o )private
private ...

private

Available since: Ext JS 3.4.0

Parameters

  • o : Object
Ext.data.Store
view source
( property, [start], [end] ) : Number
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

  • property : String

    A field in each record

  • start : Number (optional)

    The record index to start at (defaults to 0)

  • end : Number (optional)

    The last record index to include (defaults to length - 1)

Returns

Suspend the firing of all events. ...

Suspend 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;

( eventName, handler, [scope] )
Removes an event handler (shorthand for removeListener.) ...

Removes an event handler (shorthand for removeListener.)

Available since: 1.1.0

Parameters

  • eventName : String

    The type of event the handler was associated with.

  • handler : 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.

Ext.data.Store
view source
( store, record, action )private
updateRecord Should not be used directly. ...

updateRecord Should not be used directly. This method will be called automatically if a Writer is set. Listens to 'update' event.

Available since: Ext JS 3.4.0

Parameters

  • store : Object
  • record : Object
  • action : Object
Defined By

Events

Ext.data.Store
view source
( this, records, index )
Fires when Records have been added to the Store ...

Fires when Records have been added to the Store

Available since: 1.1.0

Parameters

  • this : Store
  • records : Ext.data.Record[]

    The array of Records added

  • index : Number

    The index at which the record(s) were added

Ext.data.Store
view source
( this, options )
Fires before a request is made for a new data object. ...

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: 1.1.0

Parameters

  • this : Store
  • options : Object

    The loading options that were specified (see load for details)

Ext.data.Store
view source
( store, data )
Fires before a save action is called. ...

Fires before a save action is called. A save encompasses destroying records, updating records and creating records.

Available since: Ext JS 3.4.0

Parameters

  • store : Ext.data.Store
  • data : Object

    An object containing the data that is to be saved. The object will contain a key for each appropriate action, with an array of records for each action.

Ext.data.Store
view source
( store, action, rs, options, arg )
...

Available since: Ext JS 3.4.0

Parameters

  • store : Ext.data.Store
  • action : String

    [Ext.data.Api.actions.create|update|destroy]

  • rs : Record/Record[]

    The Record(s) being written.

  • options : Object

    The loading options that were specified. Edit options.params to add Http parameters to the request. (see save for details)

  • arg : Object

    The callback's arg object passed to the request function

Ext.data.Store
view source
( this, records )
Fires when the data cache has been cleared. ...

Fires when the data cache has been cleared.

Available since: 1.1.0

Parameters

  • this : Store
  • records : Record[]

    The records that were cleared.

Ext.data.Store
view source
( 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.

Available since: 1.1.0

Parameters

  • this : Store
Ext.data.Store
view source
( misc )
Fires if an exception occurs in the Proxy during a remote request. ...

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.

Available since: Ext JS 3.4.0

Parameters

Ext.data.Store
view source
( this, records, options )
Fires after a new set of Records has been loaded. ...

Fires after a new set of Records has been loaded.

Available since: 1.1.0

Parameters

  • this : Store
  • records : Ext.data.Record[]

    The Records that were loaded

  • options : Object

    The loading options that were specified (see load for details)

Ext.data.Store
view source
( misc )
This event is deprecated in favor of the catch-all exception event instead. ...

This event is deprecated in favor of the catch-all exception event instead.

This event is relayed through the corresponding Ext.data.DataProxy. See Ext.data.DataProxy.loadexception for additional details.

Available since: 1.1.0

Parameters

Ext.data.Store
view source
( this, meta )
Fires when this store's reader provides new metadata (fields). ...

Fires when this store's reader provides new metadata (fields). This is currently only supported for JsonReaders.

Available since: 1.1.0

Parameters

  • this : Store
  • meta : Object

    The JSON metadata

Ext.data.Store
view source
( this, record, index )
Fires when a Record has been removed from the Store ...

Fires when a Record has been removed from the Store

Available since: 1.1.0

Parameters

  • this : Store
  • record : Ext.data.Record

    The Record that was removed

  • index : Number

    The index at which the record was removed

Ext.data.Store
view source
( store, batch, data )
Fires after a save is completed. ...

Fires after a save is completed. A save encompasses destroying records, updating records and creating records.

Available since: Ext JS 3.4.0

Parameters

  • store : Ext.data.Store
  • batch : Number

    The identifier for the batch that was saved.

  • data : Object

    An object containing the data that is to be saved. The object will contain a key for each appropriate action, with an array of records for each action.

Ext.data.Store
view source
( this, record, operation )
Fires when a Record has been updated ...

Fires when a Record has been updated

Available since: 1.1.0

Parameters

  • this : Store
  • record : Ext.data.Record

    The Record that was updated

  • operation : String

    The update operation being performed. Value may be one of:

         Ext.data.Record.EDIT
         Ext.data.Record.REJECT
         Ext.data.Record.COMMIT
    
Ext.data.Store
view source
( store, action, result, res, rs )
Fires if the server returns 200 after an Ext.data.Api.actions CRUD action. ...

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).

Available since: Ext JS 3.4.0

Parameters

  • store : Ext.data.Store
  • action : String

    [Ext.data.Api.actions.create|update|destroy]

  • result : Object

    The 'data' picked-out out of the response for convenience.

  • res : Ext.Direct.Transaction
  • rs : Record/Record[]

    Store's records, the subject(s) of the write-action