| |
Ext.data.Record.create
(
Array o,
[Array o]
)
: function
Generate a constructor for a specif...
Generate a constructor for a specific record layout.
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:
- 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 {@link Ext.grid.ColumnModel}
- 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.
为指定的record布局生成一构建器
每一个字段字义对象可以包含下列属性:
- name : String
一个名字(通过该名字,在record中引用字段).
如例 dataIndex 属性 在列定义对象中传到 Ext.grid.ColumnModel
- mapping : String
(可选项) Ext.data.Reader的实现使用的路径规范,它创建Record来访问数据对象中的数据值
如果一Ext.data.JsonReader被使用,那么该字符串包含javascript 表达式来引用record条目的根与数据的关系
如果使用Ext.data.XmlReader, 这将是个数据条目与记录对象关系的Ext.DomQuery路径,如果映射表达式与字段名相同。则可省略
- type : String
(可选项) 转换成显示值的数据类型. 可能的值是
- auto (默认情况下不作转换)
- 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
(可选项) Ext.data.SortTypes的数值
- sortDir : String
(可选项) 初始化排序方向 "ASC" or "DESC"
- convert : Function
(可选项)一个函数用来转换由reader提供的值成一个将被存入Reader中的对象,
它将有如下参数被传入:
- dateFormat : String
(可选项) Date.parseDate函数的一格式.
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);
In the simplest case, if no properties other than name are required, a field definition
may consist of just a field name string.
@method create
to the definition.
@static
参数项:
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.
为指定的record布局生成一构建器
o : Array
一字段定义对象的数组,其指定了字段名,随意的数据类型。及Ext.dataReader从一数据对象选取字段值的映射。
每一个字段字义对象可以包含下列属性:
- name : String
一个名字(通过该名字,在record中引用字段).
如例 dataIndex 属性 在列定义对象中传到 Ext.grid.ColumnModel
- mapping : String
(可选项) Ext.data.Reader的实现使用的路径规范,它创建Record来访问数据对象中的数据值
如果一Ext.data.JsonReader被使用,那么该字符串包含javascript 表达式来引用record条目的根与数据的关系
如果使用Ext.data.XmlReader, 这将是个数据条目与记录对象关系的Ext.DomQuery路径,如果映射表达式与字段名相同。则可省略
- type : String
(可选项) 转换成显示值的数据类型. 可能的值是
- auto (默认情况下不作转换)
- 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
(可选项) Ext.data.SortTypes的数值
- sortDir : String
(可选项) 初始化排序方向 "ASC" or "DESC"
- convert : Function
(可选项)一个函数用来转换由reader提供的值成一个将被存入Reader中的对象,
它将有如下参数被传入:
- dateFormat : String
(可选项) Date.parseDate函数的一格式.
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);
In the simplest case, if no properties other than name are required, a field definition
may consist of just a field name string.
@method create
to the definition.
@static
返回:
function A constructor which is used to create new Records according
|
Record
|