PageRenderTime 29ms CodeModel.GetById 21ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/ext-4.0.7/examples/grid/xml-grid.js

https://bitbucket.org/srogerf/javascript
JavaScript | 64 lines | 39 code | 4 blank | 21 comment | 0 complexity | 385648aa204302432692229c77ecd870 MD5 | raw file
 1/*
 2
 3This file is part of Ext JS 4
 4
 5Copyright (c) 2011 Sencha Inc
 6
 7Contact:  http://www.sencha.com/contact
 8
 9GNU General Public License Usage
10This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14*/
15Ext.require([
16    'Ext.data.*',
17    'Ext.grid.*'
18]);
19
20Ext.onReady(function(){
21    Ext.define('Book',{
22        extend: 'Ext.data.Model',
23        fields: [
24            // set up the fields mapping into the xml doc
25            // The first needs mapping, the others are very basic
26            {name: 'Author', mapping: 'ItemAttributes > Author'},
27            'Title', 'Manufacturer', 'ProductGroup'
28        ]
29    });
30
31    // create the Data Store
32    var store = Ext.create('Ext.data.Store', {
33        model: 'Book',
34        autoLoad: true,
35        proxy: {
36            // load using HTTP
37            type: 'ajax',
38            url: 'sheldon.xml',
39            // the return will be XML, so lets set up a reader
40            reader: {
41                type: 'xml',
42                // records will have an "Item" tag
43                record: 'Item',
44                idProperty: 'ASIN',
45                totalRecords: '@total'
46            }
47        }
48    });
49
50    // create the grid
51    var grid = Ext.create('Ext.grid.Panel', {
52        store: store,
53        columns: [
54            {text: "Author", flex: 1, dataIndex: 'Author', sortable: true},
55            {text: "Title", width: 180, dataIndex: 'Title', sortable: true},
56            {text: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
57            {text: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
58        ],
59        renderTo:'example-grid',
60        width: 540,
61        height: 200
62    });
63});
64