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