Class LABKEY.ext.Store
Extends
Ext.data.Store.
LabKey extension to the Ext.data.Store class,
which can retrieve data from a LabKey server, track changes, and update the server upon demand. This is most typically
used with data-bound user interface widgets, such as the Ext.grid.EditorGridPanel.
If you use any of the LabKey APIs that extend Ext APIs, you must either make your code open source or purchase an Ext license.
Additional Documentation:
Defined in: Store.js.
Constructor Attributes | Constructor Name and Description |
---|---|
LABKEY.ext.Store(config)
Constructs a new LabKey Store using the supplied configuration.
|
Config Attributes | Config Name and Description |
---|---|
A comma-delimited list of column names to fetch from the specified query.
|
|
The container filter to use for this query (defaults to null).
|
|
The container path from which to get the data.
|
|
An array of LABKEY.Filter.FilterDefinition objects to use as the base filters.
|
|
True will ignore any filters applied as part of the view (defaults to false).
|
|
The maximum number of rows returned by this query (defaults to showing all rows).
|
|
Specify parameters for parameterized queries.
|
|
The query name within the schema to fetch.
|
|
The LabKey schema to query.
|
|
A base sort specification in the form of '[-]column,[-]column' ('-' is used for descending sort).
|
|
A LabKey SQL statement to execute to fetch the data.
|
|
Defaults to true.
|
|
A saved custom view of the specified query to use if desired.
|
Method Attributes | Method Name and Description |
---|---|
addRecord(data, index)
Adds a new record to the store based upon a raw data object.
|
|
Commits all changes made locally to the server.
|
|
deleteRecords(records)
Deletes a set of records from the store as well as the server.
|
|
isUpdateInProgress(record)
Returns true if the given record is currently being updated on the server, false if not.
|
Event Attributes | Event Name and Description |
---|---|
beforecommit(records, rows)
Fired just before the store sends updated records to the server for saving.
|
|
Fired after all modified records have been saved on the server.
|
|
commitexception(message)
Fired if there was an exception during the save process.
|
<div id="div1"/> <script type="text/javascript"> // This sample code uses LABKEY.ext.Store to hold data from the server's Users table. // Ext.grid.EditorGridPanel provides a user interface for updating the Phone column. // On pressing the 'Submit' button, any changes made in the grid are submitted to the server. var _store = new LABKEY.ext.Store({ schemaName: 'core', queryName: 'Users', columns: "DisplayName, Phone", autoLoad: true }); var _grid = new Ext.grid.EditorGridPanel({ title: 'Users - Change Phone Number', store: _store, renderTo: 'div1', autoHeight: true, columnLines: true, viewConfig: { forceFit: true }, colModel: new Ext.grid.ColumnModel({ columns: [{ header: 'User Name', dataIndex: 'DisplayName', hidden: false, width: 150 }, { header: 'Phone Number', dataIndex: 'Phone', hidden: false, sortable: true, width: 100, editor: new Ext.form.TextField() }] }), buttons: [{ text: 'Save', handler: function () { _grid.getStore().commitChanges(); alert("Number of records changed: " + _grid.getStore().getModifiedRecords().length); } }, { text: 'Cancel', handler: function () { _grid.getStore().rejectChanges(); } }] }); </script>
- Parameters:
- config
- Configuration properties.
- "Current": Include the current folder only
- "CurrentAndSubfolders": Include the current folder and all subfolders
- "CurrentPlusProject": Include the current folder and the project that contains it
- "CurrentAndParents": Include the current folder and its parent folders
- "CurrentPlusProjectAndShared": Include the current folder plus its project plus any shared folders
- "AllFolders": Include all folders for which the user has read permission
- Parameters:
- {Object} data
- The raw data object containing a properties for each field.
- {number} index Optional
- The index at which to insert the record. If not supplied, the new record will be added to the end of the store.
- Returns:
- {Ext.data.Record} The new Ext.data.Record object.
Before records are sent to the server, the "beforecommit" event will fire. Return false from your event handler to prohibit the commit. The beforecommit event handler will be passed the following parameters:
- records: An array of Ext.data.Record objects that will be sent to the server.
- rows: An array of row data objects from those records.
The "commitcomplete" or "commitexception" event will be fired when the server responds. The former is fired if all records are successfully saved, and the latter if an exception occurred. All modifications to the server are transacted together, so all records will be saved or none will be saved. The "commitcomplete" event is passed no parameters. The "commitexception" even is passed the error message as the only parameter. You may return false form the "commitexception" event to supress the default display of the error message.
For information on the Ext event model, see the Ext API documentation.
- Parameters:
- {Array of Ext.data.Record objects} records
- The records to delete.
- Parameters:
- {Ext.data.Record} record
- The record.
- Returns:
- {boolean} true if the record is currently being updated, false if not.
- Parameters:
- {array} records
- An array of Ext.data.Record objects that will be saved.
- {array} rows
- An array of simple row-data objects from those records. These are the actual data objects that will be sent to the server.
- Parameters:
- {String} message
- The exception message.