1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | Ext.onReady(function(){ |
---|
8 | |
---|
9 | // create the Data Store |
---|
10 | var store = new Ext.data.Store({ |
---|
11 | // load using HTTP |
---|
12 | url: 'sheldon.xml', |
---|
13 | |
---|
14 | // the return will be XML, so lets set up a reader |
---|
15 | reader: new Ext.data.XmlReader({ |
---|
16 | // records will have an "Item" tag |
---|
17 | record: 'Item', |
---|
18 | id: 'ASIN', |
---|
19 | totalRecords: '@total' |
---|
20 | }, [ |
---|
21 | // set up the fields mapping into the xml doc |
---|
22 | // The first needs mapping, the others are very basic |
---|
23 | {name: 'Author', mapping: 'ItemAttributes > Author'}, |
---|
24 | 'Title', 'Manufacturer', 'ProductGroup' |
---|
25 | ]) |
---|
26 | }); |
---|
27 | |
---|
28 | // create the grid |
---|
29 | var grid = new Ext.grid.GridPanel({ |
---|
30 | store: store, |
---|
31 | columns: [ |
---|
32 | {header: "Author", width: 120, dataIndex: 'Author', sortable: true}, |
---|
33 | {header: "Title", width: 180, dataIndex: 'Title', sortable: true}, |
---|
34 | {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true}, |
---|
35 | {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true} |
---|
36 | ], |
---|
37 | renderTo:'example-grid', |
---|
38 | width:540, |
---|
39 | height:200 |
---|
40 | }); |
---|
41 | |
---|
42 | store.load(); |
---|
43 | }); |
---|