View Full Version : API Documentation for Ext.data.Record

18 Apr 2007, 12:52 AM

I'm looking for API documentation for Ext.data.Record. Ext.data.XmlReader links to Ext.data.Record.html, but that doesn't exist.

More specifically I'm looking for the different types that are supported in a reader.
reader: new Ext.data.ArrayReader({id: 0}, [
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}

What other values are allowed for type here?

18 Apr 2007, 1:00 AM
You are right... the Ext.data.Record documentation is missing. However... if you try to open source/data/Record.js from the download package you can see the various types on line 45/46 or look at the source in source/data/DataField.js on lines 44-92 :)

18 Apr 2007, 2:08 AM
Possibly the doc generator might have a problem, because in SVN, the Ext.data.Record.create function has the following comment which contains the required info:

* Generate a constructor for a specific record layout.
* @param {Array} o An Array of field definition objects which specify field names, and optionally,
* data types, and a mapping for an {@link Ext.data.Reader} to extract the field's value from a data object.
* Each field definition object may contain the following properties: <ul>
* <li>name {String} The name by which the field is referenced within the Record. This is referenced by,
* for example the <em>dataIndex</em> property in column definition objects passed to {@link Ext.grid.ColumnModel}</li>
* <li>mapping {String} (Optional) A path specification for use by the {@link Ext.data.Reader} implementation
* that is creating the Record to access the data value from the data object. If an {@link 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 {@link Ext.data.XmlReader} is being used, this is an {@link 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.</li>
* <li>type {String} (Optional) The data type for conversion to displayable value. Possible values are
* "auto" (which is the default, and implies no conversion), "string", "int", "float", "boolean", "date".</li>
* <li>sortType {Mixed} (Optional) A member of {@link Ext.data.SortTypes}.</li>
* <li>sortDir {String} (Optional) Initial direction to sort. "ASC" or "DESC"</li>
* <li>convert {Function} (Optional) A function which accepts a data value and returns it formatted for display.</li>
* <li>dateFormat {String} (Optional) A format String for the Date.parseDate function.</li>
* </ul>
* <br>usage:<br><pre><code>
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!'

18 Apr 2007, 2:12 AM
Thanks, that should be what I was looking for.

Hope you can fix that generator, seems like there is quite a lot of stuff missing in the API.

18 Apr 2007, 3:38 AM
These docs will be in the next release. The problem is it doesn't have an @class so the doc parser doesn't know what it is and ignores it. ;)

18 Apr 2007, 4:13 AM
Thats cool.

Is there an easy approach to display a checkbox for a boolean column in a grid? Setting type to boolean (now at least I know that it is supported) doesn't change anything, as my data is coming from a JSON array anyway.
My attempts with a custom renderer to return the HTML for a input of type checkbox weren't very successful, but even if I get that working, the checkbox still doesn't look as cool as Ext does anywhere else.

18 Apr 2007, 8:45 AM
If it doesn't need to be editable, you could just use the Ext checkmark in your renderer

if (value === true) {
return {'<img src="' + Ext.BLANK_IMAGE_URL + '"class="x-grid-cell-check">'; <-- replace this with your own class if you want a different image.
} else {
return '';

If you want it to be editable use the checkbox from the Form class.

18 Apr 2007, 11:46 PM
Oops, my bad! :">