12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- Ext.require([
- 'Ext.data.*',
- 'Ext.grid.*'
- ]);
- Ext.onReady(function(){
- Ext.define('Book',{
- extend: 'Ext.data.Model',
- fields: [
- // 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 Data Store
- var store = Ext.create('Ext.data.Store', {
- model: 'Book',
- autoLoad: true,
- proxy: {
- // load using HTTP
- type: 'ajax',
- url: 'sheldon.xml',
- // the return will be XML, so lets set up a reader
- reader: {
- type: 'xml',
- // records will have an "Item" tag
- record: 'Item',
- idProperty: 'ASIN',
- totalRecords: '@total'
- }
- }
- });
- // create the grid
- var grid = Ext.create('Ext.grid.Panel', {
- store: store,
- columns: [
- {text: "Author", flex: 1, dataIndex: 'Author', sortable: true},
- {text: "Title", width: 180, dataIndex: 'Title', sortable: true},
- {text: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
- {text: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
- ],
- renderTo:'example-grid',
- width: 540,
- height: 200
- });
- });
|