initial import
[roojs1] / examples / grid / xml-grid.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11
12 Roo.BLANK_IMAGE_URL  = "../../images/default/s.gif";
13
14 \r
15 Roo.onReady(function(){\r
16 \r
17     // create the Data Store\r
18     var ds = new Roo.data.Store({\r
19         // load using HTTP\r
20         proxy: new Roo.data.HttpProxy({url: 'sheldon.xml'}),\r
21 \r
22         // the return will be XML, so lets set up a reader\r
23         reader: new Roo.data.XmlReader({\r
24                // records will have an "Item" tag\r
25                record: 'Item',\r
26                id: 'ASIN',\r
27                totalRecords: '@total'\r
28            }, [\r
29                // set up the fields mapping into the xml doc\r
30                // The first needs mapping, the others are very basic\r
31                {name: 'Author', mapping: 'ItemAttributes > Author'},\r
32                'Title', 'Manufacturer', 'ProductGroup'\r
33            ])\r
34     });\r
35 \r
36     var cm = new Roo.grid.ColumnModel([\r
37             {header: "Author", width: 120, dataIndex: 'Author'},\r
38                 {header: "Title", width: 180, dataIndex: 'Title'},\r
39                 {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},\r
40                 {header: "Product Group", width: 100, dataIndex: 'ProductGroup'}\r
41         ]);\r
42     cm.defaultSortable = true;\r
43 \r
44     // create the grid\r
45     var grid = new Roo.grid.Grid('example-grid', {\r
46         ds: ds,\r
47         cm: cm\r
48     });\r
49     grid.render();\r
50 \r
51     ds.load();\r
52 });\r