欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

extjs DataReader、JsonReader、XmlReader的構(gòu)造方法

 更新時間:2009年11月07日 00:29:01   作者:  
DataReader、JsonReader、XmlReader的構(gòu)造方法,需要的朋友可以參考下。
extjs3.0幫助文檔:
DataReader( Object meta, Array/Object recordType )
Create a new DataReader
參數(shù):

meta : Object
Metadata configuration options (implementation-specific).
元數(shù)據(jù)配置選項(...-...)
recordType : Array/Object
Either an Array of Field definition objects
任意一個Field定義的對象數(shù)組
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創(chuàng)建的Record結(jié)構(gòu).
返回:
void

內(nèi)部關(guān)鍵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;

得出結(jié)論:
a.recordType可以直接是一個Field結(jié)構(gòu)的數(shù)組,由內(nèi)部代碼加上Ext.data.Record.create(...)。
b.recordType可以是已經(jīng)加上Ext.data.Record.create(...)的Field數(shù)組。
c.meta中可以放屬性:idProperty。




extjs3.0幫助文檔:
XmlReader( Object meta, Object recordType )
Create a new XmlReader.
參數(shù):
meta : Object
Metadata configuration options
recordType : Object
Either an Array of field definition objects as passed to Ext.data.Record.create,
任意一個field定義的對象數(shù)組作為參數(shù)傳遞給Ext.data.Record.create
or a Record constructor object created using Ext.data.Record.create.
或者一個使用Ext.data.Record.create創(chuàng)建的Record結(jié)構(gòu)對象。
返回:
void

可以看出需要傳兩個obj進(jìn)去,

查看內(nèi)部js代碼
Ext.data.JsonReader = function(meta, recordType){
//如果沒有meta,那創(chuàng)建一個Obj給meta。
meta = meta || {};
//把idProperty等添加到meta,如果它沒有這些成員。
Ext.applyIf(meta, {
idProperty: 'id',
successProperty: 'success',
totalProperty: 'total'
});
//調(diào)用父類
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.調(diào)用了父類構(gòu)造,所以其他的跟父類一樣。


extjs3.0幫助文檔:
JsonReader( Object meta, Array/Object recordType )
Create a new JsonReader
Create a new JsonReader
參數(shù):
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

查看內(nèi)部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.調(diào)用了父類構(gòu)造,所以其他的跟父類一樣

總結(jié):...

相關(guān)文章

最新評論