Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / grid / xml-grid.js
index b072aaa..5b271dc 100644 (file)
@@ -1,43 +1,64 @@
-/*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-Ext.onReady(function(){\r
-\r
-    // create the Data Store\r
-    var store = new Ext.data.Store({\r
-        // load using HTTP\r
-        url: 'sheldon.xml',\r
-\r
-        // the return will be XML, so lets set up a reader\r
-        reader: new Ext.data.XmlReader({\r
-               // records will have an "Item" tag\r
-               record: 'Item',\r
-               id: 'ASIN',\r
-               totalRecords: '@total'\r
-           }, [\r
-               // set up the fields mapping into the xml doc\r
-               // The first needs mapping, the others are very basic\r
-               {name: 'Author', mapping: 'ItemAttributes > Author'},\r
-               'Title', 'Manufacturer', 'ProductGroup'\r
-           ])\r
-    });\r
-\r
-    // create the grid\r
-    var grid = new Ext.grid.GridPanel({\r
-        store: store,\r
-        columns: [\r
-            {header: "Author", width: 120, dataIndex: 'Author', sortable: true},\r
-            {header: "Title", width: 180, dataIndex: 'Title', sortable: true},\r
-            {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},\r
-            {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}\r
-        ],\r
-        renderTo:'example-grid',\r
-        width:540,\r
-        height:200\r
-    });\r
-\r
-    store.load();\r
-});\r
+/*
+
+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
+    });
+});
+