1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-data.Operation-method-constructor'><span id='Ext-data.Operation'>/**
2 </span></span> * @author Ed Spencer
3 * @class Ext.data.Operation
6 * <p>Represents a single read or write operation performed by a {@link Ext.data.proxy.Proxy Proxy}.
7 * Operation objects are used to enable communication between Stores and Proxies. Application
8 * developers should rarely need to interact with Operation objects directly.</p>
10 * <p>Several Operations can be batched together in a {@link Ext.data.Batch batch}.</p>
13 * @param {Object} config Optional config object
15 Ext.define('Ext.data.Operation', {
16 <span id='Ext-data.Operation-cfg-synchronous'> /**
17 </span> * @cfg {Boolean} synchronous True if this Operation is to be executed synchronously (defaults to true). This
18 * property is inspected by a {@link Ext.data.Batch Batch} to see if a series of Operations can be executed in
23 <span id='Ext-data.Operation-cfg-action'> /**
24 </span> * @cfg {String} action The action being performed by this Operation. Should be one of 'create', 'read', 'update' or 'destroy'
28 <span id='Ext-data.Operation-cfg-filters'> /**
29 </span> * @cfg {Array} filters Optional array of filter objects. Only applies to 'read' actions.
33 <span id='Ext-data.Operation-cfg-sorters'> /**
34 </span> * @cfg {Array} sorters Optional array of sorter objects. Only applies to 'read' actions.
38 <span id='Ext-data.Operation-cfg-group'> /**
39 </span> * @cfg {Object} group Optional grouping configuration. Only applies to 'read' actions where grouping is desired.
43 <span id='Ext-data.Operation-cfg-start'> /**
44 </span> * @cfg {Number} start The start index (offset), used in paging when running a 'read' action.
48 <span id='Ext-data.Operation-cfg-limit'> /**
49 </span> * @cfg {Number} limit The number of records to load. Used on 'read' actions when paging is being used.
53 <span id='Ext-data.Operation-cfg-batch'> /**
54 </span> * @cfg {Ext.data.Batch} batch The batch that this Operation is a part of (optional)
58 <span id='Ext-data.Operation-property-started'> /**
59 </span> * Read-only property tracking the start status of this Operation. Use {@link #isStarted}.
66 <span id='Ext-data.Operation-property-running'> /**
67 </span> * Read-only property tracking the run status of this Operation. Use {@link #isRunning}.
74 <span id='Ext-data.Operation-property-complete'> /**
75 </span> * Read-only property tracking the completion status of this Operation. Use {@link #isComplete}.
82 <span id='Ext-data.Operation-property-success'> /**
83 </span> * Read-only property tracking whether the Operation was successful or not. This starts as undefined and is set to true
84 * or false by the Proxy that is executing the Operation. It is also set to false by {@link #setException}. Use
85 * {@link #wasSuccessful} to query success status.
92 <span id='Ext-data.Operation-property-exception'> /**
93 </span> * Read-only property tracking the exception status of this Operation. Use {@link #hasException} and see {@link #getError}.
100 <span id='Ext-data.Operation-property-error'> /**
101 </span> * The error object passed when {@link #setException} was called. This could be any object or primitive.
108 constructor: function(config) {
109 Ext.apply(this, config || {});
112 <span id='Ext-data.Operation-method-setStarted'> /**
113 </span> * Marks the Operation as started
115 setStarted: function() {
120 <span id='Ext-data.Operation-method-setCompleted'> /**
121 </span> * Marks the Operation as completed
123 setCompleted: function() {
124 this.complete = true;
125 this.running = false;
128 <span id='Ext-data.Operation-method-setSuccessful'> /**
129 </span> * Marks the Operation as successful
131 setSuccessful: function() {
135 <span id='Ext-data.Operation-method-setException'> /**
136 </span> * Marks the Operation as having experienced an exception. Can be supplied with an option error message/object.
137 * @param {Mixed} error Optional error string/object
139 setException: function(error) {
140 this.exception = true;
141 this.success = false;
142 this.running = false;
146 <span id='Ext-data.Operation-method-hasException'> /**
147 </span> * Returns true if this Operation encountered an exception (see also {@link #getError})
148 * @return {Boolean} True if there was an exception
150 hasException: function() {
151 return this.exception === true;
154 <span id='Ext-data.Operation-method-getError'> /**
155 </span> * Returns the error string or object that was set using {@link #setException}
156 * @return {Mixed} The error object
158 getError: function() {
162 <span id='Ext-data.Operation-method-getRecords'> /**
163 </span> * Returns an array of Ext.data.Model instances as set by the Proxy.
164 * @return {Array} Any loaded Records
166 getRecords: function() {
167 var resultSet = this.getResultSet();
169 return (resultSet === undefined ? this.records : resultSet.records);
172 <span id='Ext-data.Operation-method-getResultSet'> /**
173 </span> * Returns the ResultSet object (if set by the Proxy). This object will contain the {@link Ext.data.Model model} instances
174 * as well as meta data such as number of instances fetched, number available etc
175 * @return {Ext.data.ResultSet} The ResultSet object
177 getResultSet: function() {
178 return this.resultSet;
181 <span id='Ext-data.Operation-method-isStarted'> /**
182 </span> * Returns true if the Operation has been started. Note that the Operation may have started AND completed,
183 * see {@link #isRunning} to test if the Operation is currently running.
184 * @return {Boolean} True if the Operation has started
186 isStarted: function() {
187 return this.started === true;
190 <span id='Ext-data.Operation-method-isRunning'> /**
191 </span> * Returns true if the Operation has been started but has not yet completed.
192 * @return {Boolean} True if the Operation is currently running
194 isRunning: function() {
195 return this.running === true;
198 <span id='Ext-data.Operation-method-isComplete'> /**
199 </span> * Returns true if the Operation has been completed
200 * @return {Boolean} True if the Operation is complete
202 isComplete: function() {
203 return this.complete === true;
206 <span id='Ext-data.Operation-method-wasSuccessful'> /**
207 </span> * Returns true if the Operation has completed and was successful
208 * @return {Boolean} True if successful
210 wasSuccessful: function() {
211 return this.isComplete() && this.success === true;
214 <span id='Ext-data.Operation-method-setBatch'> /**
216 * Associates this Operation with a Batch
217 * @param {Ext.data.Batch} batch The batch
219 setBatch: function(batch) {
223 <span id='Ext-data.Operation-method-allowWrite'> /**
224 </span> * Checks whether this operation should cause writing to occur.
225 * @return {Boolean} Whether the operation should cause a write to occur.
227 allowWrite: function() {
228 return this.action != 'read';
230 });</pre></pre></body></html>