-<!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.Model-method-constructor'><span id='Ext-data.Model'>/**
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-data-Model-method-constructor'><span id='Ext-data-Model'>/**
</span></span> * @author Ed Spencer
* @class Ext.data.Model
*
// Fire the onModelDefined template method on ModelManager
Ext.ModelManager.onModelDefined(cls);
});
- }
+ };
},
inheritableStatics: {
-<span id='Ext-data.Model-method-setProxy'> /**
+<span id='Ext-data-Model-method-setProxy'> /**
</span> * Sets the Proxy to use for this model. Accepts any options that can be accepted by {@link Ext#createByAlias Ext.createByAlias}
* @param {String/Object/Ext.data.proxy.Proxy} proxy The proxy
* @static
return proxy;
},
-<span id='Ext-data.Model-method-getProxy'> /**
+<span id='Ext-data-Model-method-getProxy'> /**
</span> * Returns the configured Proxy for this Model
* @return {Ext.data.proxy.Proxy} The proxy
*/
return this.proxy;
},
-<span id='Ext-data.Model-method-load'> /**
+<span id='Ext-data-Model-method-load'> /**
</span> * <b>Static</b>. Asynchronously loads a model instance by id. Sample usage:
<pre><code>
MyApp.User = Ext.define('User', {
REJECT : 'reject',
COMMIT : 'commit',
-<span id='Ext-data.Model-method-id'> /**
+<span id='Ext-data-Model-method-id'> /**
</span> * Generates a sequential id. This method is typically called when a record is {@link #create}d
* and {@link #Record no id has been specified}. The id will automatically be assigned
* to the record. The returned id takes the form:
}
},
-<span id='Ext-data.Model-property-editing'> /**
+<span id='Ext-data-Model-property-editing'> /**
</span> * Internal flag used to track whether or not the model instance is currently being edited. Read-only
* @property editing
* @type Boolean
*/
editing : false,
-<span id='Ext-data.Model-property-dirty'> /**
+<span id='Ext-data-Model-property-dirty'> /**
</span> * Readonly flag - true if this Record has been modified.
* @type Boolean
*/
dirty : false,
-<span id='Ext-data.Model-cfg-persistanceProperty'> /**
+<span id='Ext-data-Model-cfg-persistanceProperty'> /**
</span> * @cfg {String} persistanceProperty The property on this Persistable object that its data is saved to.
* Defaults to 'data' (e.g. all persistable data resides in this.data.)
*/
evented: false,
isModel: true,
-<span id='Ext-data.Model-property-phantom'> /**
+<span id='Ext-data-Model-property-phantom'> /**
</span> * <tt>true</tt> when the record does not yet exist in a server-side database (see
* {@link #setDirty}). Any record which has a real database pk set as its id property
* is NOT a phantom -- it's real.
*/
phantom : false,
-<span id='Ext-data.Model-cfg-idProperty'> /**
+<span id='Ext-data-Model-cfg-idProperty'> /**
</span> * @cfg {String} idProperty The name of the field treated as this Model's unique id (defaults to 'id').
*/
idProperty: 'id',
-<span id='Ext-data.Model-property-defaultProxyType'> /**
+<span id='Ext-data-Model-property-defaultProxyType'> /**
</span> * The string type of the default Model Proxy. Defaults to 'ajax'
* @property defaultProxyType
* @type String
*/
defaultProxyType: 'ajax',
-<span id='Ext-data.Model-property-fields'> /**
+<span id='Ext-data-Model-property-fields'> /**
</span> * An array of the fields defined on this model
* @property fields
* @type {Array}
*/
- constructor: function(data, id) {
+ // raw not documented intentionally, meant to be used internally.
+ constructor: function(data, id, raw) {
data = data || {};
var me = this,
isArray = Ext.isArray(data),
newData = isArray ? {} : null; // to hold mapped array data if needed
-<span id='Ext-data.Model-property-internalId'> /**
+<span id='Ext-data-Model-property-internalId'> /**
</span> * An internal unique ID for each Model instance, used to identify Models that don't have an ID yet
* @property internalId
* @type String
* @private
*/
me.internalId = (id || id === 0) ? id : Ext.data.Model.id(me);
+
+<span id='Ext-data-Model-property-raw'> /**
+</span> * The raw data used to create this model if created via a reader.
+ * @property raw
+ * @type Object
+ */
+ me.raw = raw;
Ext.applyIf(me, {
data: {}
});
-<span id='Ext-data.Model-property-modified'> /**
+<span id='Ext-data-Model-property-modified'> /**
</span> * Key: value pairs of all fields whose values have changed
* @property modified
* @type Object
Ext.ModelManager.register(me);
},
-<span id='Ext-data.Model-method-get'> /**
+<span id='Ext-data-Model-method-get'> /**
</span> * Returns the value of the given field
* @param {String} fieldName The field to fetch the value for
* @return {Mixed} The value
return this[this.persistanceProperty][field];
},
-<span id='Ext-data.Model-method-set'> /**
+<span id='Ext-data-Model-method-set'> /**
</span> * Sets the given field to the given value, marks the instance as dirty
* @param {String|Object} fieldName The field to set, or an object containing key/value pairs
* @param {Mixed} value The value to set
}
},
-<span id='Ext-data.Model-method-isEqual'> /**
+<span id='Ext-data-Model-method-isEqual'> /**
</span> * Checks if two values are equal, taking into account certain
* special factors, for example dates.
* @private
return a === b;
},
-<span id='Ext-data.Model-method-beginEdit'> /**
+<span id='Ext-data-Model-method-beginEdit'> /**
</span> * Begin an edit. While in edit mode, no events (e.g.. the <code>update</code> event)
* are relayed to the containing store. When an edit has begun, it must be followed
* by either {@link #endEdit} or {@link #cancelEdit}.
}
},
-<span id='Ext-data.Model-method-cancelEdit'> /**
+<span id='Ext-data-Model-method-cancelEdit'> /**
</span> * Cancels all changes made in the current edit operation.
*/
cancelEdit : function(){
}
},
-<span id='Ext-data.Model-method-endEdit'> /**
+<span id='Ext-data-Model-method-endEdit'> /**
</span> * End an edit. If any data was modified, the containing store is notified
* (ie, the store's <code>update</code> event will fire).
* @param {Boolean} silent True to not notify the store of the change
}
},
-<span id='Ext-data.Model-method-getChanges'> /**
+<span id='Ext-data-Model-method-getChanges'> /**
</span> * Gets a hash of only the fields that have been modified since this Model was created or commited.
* @return Object
*/
return changes;
},
-<span id='Ext-data.Model-method-isModified'> /**
+<span id='Ext-data-Model-method-isModified'> /**
</span> * Returns <tt>true</tt> if the passed field name has been <code>{@link #modified}</code>
* since the load or last commit.
* @param {String} fieldName {@link Ext.data.Field#name}
return this.modified.hasOwnProperty(fieldName);
},
-<span id='Ext-data.Model-method-setDirty'> /**
+<span id='Ext-data-Model-method-setDirty'> /**
</span> * <p>Marks this <b>Record</b> as <code>{@link #dirty}</code>. This method
* is used interally when adding <code>{@link #phantom}</code> records to a
* {@link Ext.data.Store#writer writer enabled store}.</p>
},
//</debug>
-<span id='Ext-data.Model-method-reject'> /**
+<span id='Ext-data-Model-method-reject'> /**
</span> * Usually called by the {@link Ext.data.Store} to which this model instance has been {@link #join joined}.
* Rejects all changes made to the model instance since either creation, or the last commit operation.
* Modified fields are reverted to their original values.
}
},
-<span id='Ext-data.Model-method-commit'> /**
+<span id='Ext-data-Model-method-commit'> /**
</span> * Usually called by the {@link Ext.data.Store} which owns the model instance.
* Commits all changes made to the instance since either creation or the last commit operation.
* <p>Developers should subscribe to the {@link Ext.data.Store#update} event
}
},
-<span id='Ext-data.Model-method-copy'> /**
+<span id='Ext-data-Model-method-copy'> /**
</span> * Creates a copy (clone) of this Model instance.
* @param {String} id (optional) A new id, defaults to the id
* of the instance being copied. See <code>{@link #id}</code>.
return new me.self(Ext.apply({}, me[me.persistanceProperty]), newId || me.internalId);
},
-<span id='Ext-data.Model-method-setProxy'> /**
+<span id='Ext-data-Model-method-setProxy'> /**
</span> * Sets the Proxy to use for this model. Accepts any options that can be accepted by {@link Ext#createByAlias Ext.createByAlias}
* @param {String/Object/Ext.data.proxy.Proxy} proxy The proxy
* @static
return proxy;
},
-<span id='Ext-data.Model-method-getProxy'> /**
+<span id='Ext-data-Model-method-getProxy'> /**
</span> * Returns the configured Proxy for this Model
* @return {Ext.data.proxy.Proxy} The proxy
*/
return this.proxy;
},
-<span id='Ext-data.Model-method-validate'> /**
+<span id='Ext-data-Model-method-validate'> /**
</span> * Validates the current data against all of its configured {@link #validations} and returns an
* {@link Ext.data.Errors Errors} object
* @return {Ext.data.Errors} The errors object
return errors;
},
-<span id='Ext-data.Model-method-isValid'> /**
+<span id='Ext-data-Model-method-isValid'> /**
</span> * Checks if the model is valid. See {@link #validate}.
* @return {Boolean} True if the model is valid.
*/
return this.validate().isValid();
},
-<span id='Ext-data.Model-method-save'> /**
+<span id='Ext-data-Model-method-save'> /**
</span> * Saves the model instance using the configured proxy
* @param {Object} options Options to pass to the proxy
* @return {Ext.data.Model} The Model instance
return me;
},
-<span id='Ext-data.Model-method-destroy'> /**
+<span id='Ext-data-Model-method-destroy'> /**
</span> * Destroys the model using the configured proxy
* @param {Object} options Options to pass to the proxy
* @return {Ext.data.Model} The Model instance
return me;
},
-<span id='Ext-data.Model-method-getId'> /**
+<span id='Ext-data-Model-method-getId'> /**
</span> * Returns the unique ID allocated to this model instance as defined by {@link #idProperty}
* @return {Number} The id
*/
return this.get(this.idProperty);
},
-<span id='Ext-data.Model-method-setId'> /**
+<span id='Ext-data-Model-method-setId'> /**
</span> * Sets the model instance's id field to the given id
* @param {Number} id The new id
*/
this.set(this.idProperty, id);
},
-<span id='Ext-data.Model-method-join'> /**
+<span id='Ext-data-Model-method-join'> /**
</span> * Tells this model instance that it has been added to a store
* @param {Ext.data.Store} store The store that the model has been added to
*/
join : function(store) {
-<span id='Ext-data.Model-property-store'> /**
+<span id='Ext-data-Model-property-store'> /**
</span> * The {@link Ext.data.Store} to which this Record belongs.
* @property store
* @type {Ext.data.Store}
this.store = store;
},
-<span id='Ext-data.Model-method-unjoin'> /**
+<span id='Ext-data-Model-method-unjoin'> /**
</span> * Tells this model instance that it has been removed from the store
*/
unjoin: function() {
delete this.store;
},
-<span id='Ext-data.Model-method-afterEdit'> /**
+<span id='Ext-data-Model-method-afterEdit'> /**
</span> * @private
* If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's
* afterEdit method is called
this.callStore('afterEdit');
},
-<span id='Ext-data.Model-method-afterReject'> /**
+<span id='Ext-data-Model-method-afterReject'> /**
</span> * @private
* If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's
* afterReject method is called
this.callStore("afterReject");
},
-<span id='Ext-data.Model-method-afterCommit'> /**
+<span id='Ext-data-Model-method-afterCommit'> /**
</span> * @private
* If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's
* afterCommit method is called
this.callStore('afterCommit');
},
-<span id='Ext-data.Model-method-callStore'> /**
+<span id='Ext-data-Model-method-callStore'> /**
</span> * @private
* Helper function used by afterEdit, afterReject and afterCommit. Calls the given method on the
* {@link Ext.data.Store store} that this instance has {@link #join joined}, if any. The store function
}
},
-<span id='Ext-data.Model-method-getAssociatedData'> /**
+<span id='Ext-data-Model-method-getAssociatedData'> /**
</span> * Gets all of the data from this Models *loaded* associations.
* It does this recursively - for example if we have a User which
* hasMany Orders, and each Order hasMany OrderItems, it will return an object like this:
return this.prepareAssociatedData(this, [], null);
},
-<span id='Ext-data.Model-method-prepareAssociatedData'> /**
+<span id='Ext-data-Model-method-prepareAssociatedData'> /**
</span> * @private
* This complex-looking method takes a given Model instance and returns an object containing all data from
* all of that Model's *loaded* associations. See (@link #getAssociatedData}
return associationData;
}
});
-</pre></pre></body></html>
\ No newline at end of file
+</pre>
+</body>
+</html>