Properties Methods Events Direct Link

# Class Ext.data.Record

Package: | Ext.data
Defined In: | Record.js
Class: | Record
Extends: | Object

Instances of this class encapsulate both Record definition information, and Record value information for use in Ext.data.Store objects, or any code which needs to access Records cached in an Ext.data.Store object.

Constructors for this class are generated by passing an Array of field definition objects to create. Instances are usually only created by Ext.data.Reader implementations when processing unformatted data objects.

Record objects generated by this constructor inherit all the methods of Ext.data.Record listed below.

## Public Properties

Property | Defined By
--- | ---
| data : Object An object hash representing the data for this Record. | Record
| dirty : Boolean Readonly flag - true if this Record has been modified. | Record
| id : Object The unique ID of the Record as specified at construction time. | Record
| modified : Object This object contains a key and value storing the original values of all modified fields or is null if no fields have ... This object contains a key and value storing the original values of all modified fields or is null if no fields have been modified. | Record

## Public Methods

Method | Defined By
--- | ---
| Record( `Array data`, [`Object id`] ) This constructor should not be used to create Record objects. Instead, use the constructor generated by create. The p... This constructor should not be used to create Record objects. Instead, use the constructor generated by create. The parameters are the same. Parameters: `data` : Array An object, the properties of which provide values for the new Record's fields. `id` : Object (Optional) The id of the Record. This id should be unique, and is used by the Ext.data.Store object which owns the Record to index its collection of Records. If not specified an integer id is generated. Returns: `` | Record
| beginEdit() : void Begin an edit. While in edit mode, no events are relayed to the containing store. Begin an edit. While in edit mode, no events are relayed to the containing store. Parameters: None. Returns: `void` | Record
| cancelEdit() : void Cancels all changes made in the current edit operation. Cancels all changes made in the current edit operation. Parameters: None. Returns: `void` | Record
| commit( [`Boolean silent`] ) : void Usually called by the Ext.data.Store which owns the Record. Commits all changes made to the Record since either creat... Usually called by the Ext.data.Store which owns the Record. Commits all changes made to the Record since either creation, or the last commit operation. Developers should subscribe to the Ext.data.Store.update event to have their code notified of commit operations. Parameters: `silent` : Boolean (optional) True to skip notification of the owning store of the change (defaults to false) Returns: `void` | Record
| copy( [`String id`] ) : Record Creates a copy of this Record. Creates a copy of this Record. Parameters: `id` : String (optional) A new Record id if you don't want to use this Record's id Returns: `Record` | Record
- | create( [`Array o`] ) : function <static> Generate a constructor for a specific Record layout. <static> Generate a constructor for a specific Record layout. Parameters: `o` : Array An Array of field definition objects which specify field names, and optionally, data types, and a mapping for an Ext.data.Reader to extract the field's value from a data object. Each field definition object may contain the following properties: name : String The name by which the field is referenced within the Record. This is referenced by, for example, the dataIndex property in column definition objects passed to Ext.grid.ColumnModel mapping : String (Optional) A path specification for use by the Ext.data.Reader implementation that is creating the Record to access the data value from the data object. If an Ext.data.JsonReader is being used, then this is a string containing the javascript expression to reference the data relative to the Record item's root. If an Ext.data.XmlReader is being used, this is an Ext.DomQuery path to the data item relative to the Record element. If the mapping expression is the same as the field name, this may be omitted. type : String (Optional) The data type for conversion to displayable value. Possible values are auto (Default, implies no conversion) string int float boolean date sortType : Mixed (Optional) A member of Ext.data.SortTypes. sortDir : String (Optional) Initial direction to sort. "ASC" or "DESC" convert : Function (Optional) A function which converts the value provided by the Reader into an object that will be stored in the Record. It is passed the following parameters: v : Mixed The data value as read by the Reader. rec : Mixed The data object containing the row as read by the Reader. Depending on Reader type, this could be an Array, an object, or an XML element. dateFormat : String (Optional) A format String for the Date.parseDate function. defaultValue : Mixed (Optional) The default value passed to the Reader when the field does not exist in the data object (i.e. undefined). (defaults to "") usage:
      var TopicRecord = Ext.data.Record.create([
          {name: 'title', mapping: 'topic_title'},
          {name: 'author', mapping: 'username'},
          {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
          {name: 'lastPost', mapping: 'post_time', type: 'date'},
          {name: 'lastPoster', mapping: 'user2'},
          {name: 'excerpt', mapping: 'post_text'}
      ]);

      var myNewRecord = new TopicRecord({
          topic_title: 'Do my job please',
          username: 'noobie',
          topic_replies: 1,
          post_time: new Date(),
          user2: 'Animal',
          post_text: 'No way dude!'
      });
      myStore.add(myNewRecord);
In the simplest case, if no properties other than `name` are required, a field definition may consist of just a field name string. Returns: `function` A constructor which is used to create new Records according to the definition. | Record
| endEdit() : void End an edit. If any data was modified, the containing store is notified. End an edit. If any data was modified, the containing store is notified. Parameters: None. Returns: `void` | Record
| get( `String name` ) : Object Get the value of the named field. Get the value of the named field. Parameters: `name` : String The name of the field to get the value of. Returns: `Object` The value of the field. | Record
| getChanges() : Object Gets a hash of only the fields that have been modified since this Record was created or commited. Gets a hash of only the fields that have been modified since this Record was created or commited. Parameters: None. Returns: `Object` | Record
| isModified( `String fieldName` ) : Boolean Returns true if the field passed has been modified since the load or last commit. Returns true if the field passed has been modified since the load or last commit. Parameters: `fieldName` : String Returns: `Boolean` | Record
| reject( [`Boolean silent`] ) : void Usually called by the Ext.data.Store which owns the Record. Rejects all changes made to the Record since either creat... Usually called by the Ext.data.Store which owns the Record. Rejects all changes made to the Record since either creation, or the last commit operation. Modified fields are reverted to their original values. Developers should subscribe to the Ext.data.Store.update event to have their code notified of reject operations. Parameters: `silent` : Boolean (optional) True to skip notification of the owning store of the change (defaults to false) Returns: `void` | Record
| set( `String name`, `Object value` ) : void Set the named field to the specified value. Set the named field to the specified value. Parameters: `name` : String The name of the field to set. `value` : Object The value to set the field to. Returns: `void` | Record

## Public Events

This class has no public events.