/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
- /*
- This file is part of Ext JS 4
- Copyright (c) 2011 Sencha Inc
- Contact: http://www.sencha.com/contact
- GNU General Public License Usage
- This 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.
- If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
- */
- Ext.require([
- 'Ext.data.*',
- 'Ext.grid.*'
- ]);
- Ext.onReady(function(){
- Ext.define('Book',{
- extend: 'Ext.data.Model',
- fields: [
- // set up the fields mapping into the xml doc
- // The first needs mapping, the others are very basic
- {name: 'Author', mapping: 'ItemAttributes > Author'},
- 'Title', 'Manufacturer', 'ProductGroup'
- ]
- });
- // create the Data Store
- var store = Ext.create('Ext.data.Store', {
- model: 'Book',
- autoLoad: true,
- proxy: {
- // load using HTTP
- type: 'ajax',
- url: 'sheldon.xml',
- // the return will be XML, so lets set up a reader
- reader: {
- type: 'xml',
- // records will have an "Item" tag
- record: 'Item',
- idProperty: 'ASIN',
- totalRecords: '@total'
- }
- }
- });
- // create the grid
- var grid = Ext.create('Ext.grid.Panel', {
- store: store,
- columns: [
- {text: "Author", flex: 1, dataIndex: 'Author', sortable: true},
- {text: "Title", width: 180, dataIndex: 'Title', sortable: true},
- {text: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
- {text: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
- ],
- renderTo:'example-grid',
- width: 540,
- height: 200
- });
- });