当前位置: 首页 > 图文教程 > 网络编程 > Javascript > extjs DataReader、JsonReader、XmlReader的构造方法

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 extjs DataReader、JsonReader、XmlReader的构造方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 456 ::
收藏到网摘: n/a

DataReader、JsonReader、XmlReader的构造方法,需要的朋友可以参考下。 extjs3.0帮助文档:
DataReader( Object meta, Array/Object recordType )
Create a new DataReader
参数:
meta : Object
Metadata configuration options (implementation-specific).
元数据配置选项(...-...)
recordType : Array/Object
Either an Array of Field definition objects
任意一个Field定义的对象数组
which will be passed to Ext.data.Record.create,
作为对象传递给Ext.data.Record.create,
or a Record constructor created using Ext.data.Record.create.
或一个由Ext.data.Record.create创建的Record结构.
返回:
void
内部关键js代码:
Ext.data.DataReader = function(meta, recordType){
this.meta = meta;
this.recordType = Ext.isArray(recordType) ?
Ext.data.Record.create(recordType) : recordType;
this.buildExtractors();
};
...略...
rs.id = data[this.meta.idProperty];
...略...
return (data && Ext.isObject(data) &&
!Ext.isEmpty(data[this.meta.idProperty])) ? true : false;
得出结论:
a.recordType可以直接是一个Field结构的数组,由内部代码加上Ext.data.Record.create(...)。
b.recordType可以是已经加上Ext.data.Record.create(...)的Field数组。
c.meta中可以放属性:idProperty。


extjs3.0帮助文档:
XmlReader( Object meta, Object recordType )
Create a new XmlReader.
参数:
meta : Object
Metadata configuration options
recordType : Object
Either an Array of field definition objects as passed to Ext.data.Record.create,
任意一个field定义的对象数组作为参数传递给Ext.data.Record.create
or a Record constructor object created using Ext.data.Record.create.
或者一个使用Ext.data.Record.create创建的Record结构对象。
返回:
void
可以看出需要传两个obj进去,
查看内部js代码
Ext.data.JsonReader = function(meta, recordType){
//如果没有meta,那创建一个Obj给meta。
meta = meta || {};
//把idProperty等添加到meta,如果它没有这些成员。
Ext.applyIf(meta, {
idProperty: 'id',
successProperty: 'success',
totalProperty: 'total'
});
//调用父类
Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
};
...略...
var sid = this.meta.idPath || this.meta.id;
var totalRecords = 0, success = true;
if(this.meta.totalRecords){
totalRecords = q.selectNumber(this.meta.totalRecords, root, 0);
}
if(this.meta.success){
var sv = q.selectValue(this.meta.success, root, true);
success = sv !== false && sv !== 'false';
}
可知:a.meta中可以有下列属性:idProperty、successProperty、totalProperty、fields、idPath、id、totalRecords、success。
b.recordType可以为空,但要在meta中写fields。
c.调用了父类构造,所以其他的跟父类一样。

extjs3.0帮助文档:
JsonReader( Object meta, Array/Object recordType )
Create a new JsonReader
Create a new JsonReader
参数:
meta : Object
Metadata configuration options.
recordType : Array/Object
Either an Array of Field definition objects
(which will be passed to Ext.data.Record.create,
or a Record constructor created from Ext.data.Record.create.
返回:
void
查看内部js代码:
Ext.data.JsonReader = function(meta, recordType){
meta = meta || {};
Ext.applyIf(meta, {
idProperty: 'id',
successProperty: 'success',
totalProperty: 'total' });
Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
};
...略...
if (Ext.isEmpty(o[this.meta.root])) {
throw new Ext.data.JsonReader.Error('root-emtpy', this.meta.root);
}
else if (o[this.meta.root] === undefined) {
throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
}
可知:a.meta中可以有下列属性:idProperty、successProperty、totalProperty、root、fields
b.recordType可以为空,但要在meta中写fields。
c.调用了父类构造,所以其他的跟父类一样
总结:...