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