Class Ext.data.Record create方法本身就有说明字段的定义:

Class Ext.data.Record create方法本身就有说明字段的定义:

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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值