代码:
var Person=new Ext.data.Record.create(
[
{name:"personId",mapping:0},
{name:"personName",mapping:1},
{name:"personAge",mapping:2}
]
);
请问以上的name和mapping元素的说明在api的什么类里可以看得到
var Person=new Ext.data.Record.create(
[
{name:"personId",mapping:0},
{name:"personName",mapping:1},
{name:"personAge",mapping:2}
]
);
请问以上的name和mapping元素的说明在api的什么类里可以看得到
<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.