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.調用了父類構造,所以其他的跟父類一樣
總結:...
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com