Class Index | File Index

Classes


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.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new LabKey Store using the supplied configuration.
Config Summary
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 Summary
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.
 
Returns true if the given record is currently being updated on the server, false if not.
Event Summary
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.
Class Detail
LABKEY.ext.Store(config)
Constructs a new LabKey Store using the supplied configuration.
<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.
Config Detail
{String} config.columns
A comma-delimited list of column names to fetch from the specified query. Note that the names may refer to columns in related tables using the form 'column/column/column' (e.g., 'RelatedPeptide/TrimmedPeptide').

{String} config.containerFilter
The container filter to use for this query (defaults to null). Supported values include:

{String} config.containerPath
The container path from which to get the data. If not specified, the current container is used.

{Array} config.filterArray
An array of LABKEY.Filter.FilterDefinition objects to use as the base filters.

{Boolean} config.ignoreFilter
True will ignore any filters applied as part of the view (defaults to false).

{Integer} config.maxRows
The maximum number of rows returned by this query (defaults to showing all rows).

{Object} config.parameters
Specify parameters for parameterized queries.

{String} config.queryName
The query name within the schema to fetch.

{String} config.schemaName
The LabKey schema to query.

{String} config.sort
A base sort specification in the form of '[-]column,[-]column' ('-' is used for descending sort).

{String} config.sql
A LabKey SQL statement to execute to fetch the data. You may specify either a queryName or sql, but not both. Note that when using sql, the store becomes read-only, as it has no way to know how to update/insert/delete the rows.

{Boolean} config.updatable
Defaults to true. Set to false to prohibit updates to this store.

{String} config.viewName
A saved custom view of the specified query to use if desired.
Method Detail
{Ext.data.Record} addRecord(data, index)
Adds a new record to the store based upon a raw data object.
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.

commitChanges()
Commits all changes made locally to the server. This method executes the updates asynchronously, so it will return before the changes are fully made on the server. Records that are being saved will have a property called 'saveOperationInProgress' set to true, and you can test if a Record is currently being saved using the isUpdateInProgress method. Once the record has been updated on the server, its properties may change to reflect server-modified values such as Modified and ModifiedBy.

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:

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.


deleteRecords(records)
Deletes a set of records from the store as well as the server. This cannot be undone.
Parameters:
{Array of Ext.data.Record objects} records
The records to delete.

{boolean} isUpdateInProgress(record)
Returns true if the given record is currently being updated on the server, false if not.
Parameters:
{Ext.data.Record} record
The record.
Returns:
{boolean} true if the record is currently being updated, false if not.
Event Detail
beforecommit(records, rows)
Fired just before the store sends updated records to the server for saving. Return false from this event to stop the save operation.
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.

commitcomplete()
Fired after all modified records have been saved on the server.

commitexception(message)
Fired if there was an exception during the save process.
Parameters:
{String} message
The exception message.

Documentation generated by JsDoc Toolkit 2.3.2 on Tue Sep 11 2018 10:10:59 GMT-0000 (UTC)