Print Friendly

Class Ext.data.Record

Package:Ext.data
Class:Record
Extends:Object
Defined In:Record.js
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.


Properties   -  Methods   -  Events

Public Properties

Property Defined By
  dirty : Boolean Record
Readonly flag - true if this record has been modified.

Public Methods

Method Defined By
  RecordArray data, [Object id] ) Record
This constructor should not be used to create Record objects. Instead, use the constructor generated by create. The p...
  commit() : void Record
Usually called by the Ext.data.Store which owns the Record. Commits all changes made to the Record since either creat...
  copy[String id] ) : Record Record
Creates a copy of this record.
  create[Array o] ) : void Record
<static> Generate a constructor for a specific record layout.
  getString name ) : Object Record
Get the value of the named field.
  reject() : void Record
Usually called by the Ext.data.Store which owns the Record. Rejects all changes made to the Record since either creat...
  setString name, Object value ) : void Record
Set the named field to the specified value.

Public Events

This class has no public events.

Property Details

dirty

public Boolean dirty
Readonly flag - true if this record has been modified.
This property is defined by Record.

Constructor Details

Record

public function Record( Array data, [Object id] )
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 associative Array of data values keyed by the field name.
  • 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.

Method Details

commit

public function commit()
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:
  • None.
Returns:
  • void
This method is defined by Record.

copy

public function copy( [String id] )
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
This method is defined by Record.

create

public function create( [Array o] )
<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.

    • dateFormat : String

      (Optional) A format String for the {@link Date#Date.parseDate} function.


    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({
        title: 'Do my job please',
        author: 'noobie',
        totalPosts: 1,
        lastPost: new Date(),
        lastPoster: 'Animal',
        excerpt: 'No way dude!'
    });
    myStore.add(myNewRecord);
Returns:
  • void
This method is defined by Record.

get

public function get( String name )
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.
This method is defined by Record.

reject

public function reject()
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:
  • None.
Returns:
  • void
This method is defined by Record.

set

public function set( String name, Object 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
This method is defined by Record.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.