日期:2014-05-16 浏览次数:20373 次
读取XML文件来构造grid
先了解一个函数:Ext.data.XmlReader(?Object?meta
,?Object?recordType
?)
API文档解释:
?
Data reader class to create an Array of?Ext.data.Record?objects from an XML document based on mappings in a provided?Ext.data.Record?constructor.
Note: that in order for the browser to parse a returned XML document, the Content-Type header in the HTTP response must be set to "text/xml" or "application/xml".
?
Create a new XmlReader.
meta
?: Object
recordType
?: Object
?
给一个例子:
?
var Employee = Ext.data.Record.create([ {name: 'name', mapping: 'name'}, // 同名就可以不写"mapping" ,甚至可以简单到只有'name' {name: 'occupation'} // 同名 ]); var myReader = new Ext.data.XmlReader({ totalProperty: "results", // The element which contains the total dataset size (optional) record: "row", // The repeated element which contains row information idProperty: "id" // The element within the row that provides an ID for the record (optional) messageProperty: "msg" // The element within the response that provides a user-feedback message (optional) }, Employee); /