ExtJs 读取 Xml 数据
2011-03-31 14:33
281 查看
ExtJs 中使用 GridPanel 读取 Xml 文件时,如何配置 Store 的 URL属性,以及 Xml 文件的存放位置(asp.net版)。 /* * 官方示例代码 */ Ext.onReady(function(){ // create the Data Store var store = new Ext.data.Store({ /* load using HTTP,注意这里的URL属性 在通过IIS或Tomcat运行程序时,Xml文件应保证与HTML页面文件在同一文件夹内 或者确实采用远程访问方式,本地没有Xml文件,URL属性为:'http://extjs.com/deploy/dev/examples/grid/sheldon.xml' */ url: 'sheldon.xml', // the return will be XML, so lets set up a reader reader: new Ext.data.XmlReader({ // records will have an "Item" tag record: 'Item', id: 'ASIN', totalRecords: '@total' }, [ // set up the fields mapping into the xml doc // The first needs mapping, the others are very basic {name: 'Author', mapping: 'ItemAttributes > Author'}, 'Title', 'Manufacturer', 'ProductGroup' ]) }); // create the grid var grid = new Ext.grid.GridPanel({ store: store, columns: [ {header: "Author", width: 120, dataIndex: 'Author', sortable: true}, {header: "Title", width: 180, dataIndex: 'Title', sortable: true}, {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true}, {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true} ], renderTo:'example-grid', width:540, height:200 }); store.load(); }); /* * 个人代码 * 将grid显示在TabPanel中 */ Ext.onReady(function westPanel() { var store = new Ext.data.Store({ url: 'ExcellentStaffList.xml', reader: new Ext.data.XmlReader({ record: 'StaffInfo', id: 'ID', totalRecords: 'Results' }, [ 'Name','Position' ]) }); store.load(); var wpanel = new Ext.TabPanel({ renderTo: 'wPanel', activeTab: 0, width: 200, items: [{ title: '优秀员工', xtype: 'grid', frame: true, autoHeight: true, store: store, autoExparidColumn: 'Name', columns: [ { header: "姓名", dataIndex: 'Name' }, { header: "职位", dataIndex: 'Position' } ] }, { title: '部门奖励', html: '<img src="../Image/badge.jpg" height=100>' }] }); });
相关文章推荐
- Extjs 数据读取对象ArrayReader/JsonReader/XmlReader
- Extjs GridPanel用XmlReader读取xml文件的数据
- Extjs GridPanel用XmlReader读取xml文件的数据
- Extjs mvc 读取XML数据到form
- Extjs 数据读取对象ArrayReader/JsonReader/XmlReader
- Extjs GridPanel用XmlReader读取xml文件的数据 及mapping的使用规则
- extjs中model的HasMany和belongTo读取xml数据的用法
- 读写xml所有节点个人小结 和 读取xml节点的数据总结
- Silverlight制作一个简单的菜单1-用到的知识讲解 xml数据读取,事件如何传递参数
- XML-----2、Java读取XML数据
- 读取xml节点的数据总结(.net 2.0)
- word 另存为xml后,读取xml的图片数据
- 利用Flash AS2.0实现读取php xml数据和插入记录
- ExtJS与PHP Json、MYSQL数据读取
- xml文件处理的好工具--读取数据篇--cnjsp.org
- PHP中使用xmlreader读取xml数据示例
- Qt读取JSON和XML数据
- ZendFramework学习第三章(核心组件—使用配置数据之从XML配置文件中读取数据)
- 从数据库读取数据后输出XML
- javascript 读取XML数据,在页面中展现、编辑、保存的实现