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進去,
查看內(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é):...
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進去,
查看內(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)文章
ext combox 下拉框不出現(xiàn)自動提示,自動選中的解決方法
ext combox 如果想實現(xiàn)類似于 baidu 搜索時的提示功能。必須禁止其分頁功能才可以。2010-02-02
ExtJs 學習筆記 Ext.Panle Ext.TabPanel Ext.Viewport
ExtJs 學習筆記基礎(chǔ)篇 面板的使用(Ext.Panle、Ext.TabPanel、Ext.Viewport)2008-12-12
extjs ColumnChart設(shè)置不同的顏色實現(xiàn)代碼
extjs為ColumnChart設(shè)置不同的顏色想必有很多朋友還是比較陌生的吧,接下來為大家詳細介紹下具體設(shè)置代碼,感興趣的朋友可以參考下哈2013-05-05
Extjs中ComboBox加載并賦初值的實現(xiàn)方法
當需要為ComboBox加載數(shù)據(jù)后進行賦初始選中項的話,如果是寫在store.load()之后2012-03-03
Extjs4.0設(shè)置Ext.data.Store傳參的請求方式(默認為GET)
本教程將詳細介紹下設(shè)置Ext.data.Store傳參的請求方式;亮點,設(shè)置請求方式,默認為GET,感興趣的朋友可以參考下哈2013-04-04

