]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/modern/src/view/NestedLoading.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / modern / src / view / NestedLoading.js
CommitLineData
6527f429
DM
1/*\r
2 * This panel sets up a DataView, which defines an XTemplate used to render our data. We also set up\r
3 * the toolbar with the "Load Nested Data" button here\r
4 */\r
5Ext.define('KitchenSink.view.NestedLoading', {\r
6 extend: 'Ext.Container',\r
7\r
8 layout: 'fit',\r
9 items: [{\r
10 docked: 'top',\r
11 xtype: 'toolbar',\r
12 items: [{\r
13 text: 'Load Nested Data',\r
14 handler: function() {\r
15 Ext.getCmp('NestedLoadingDataView').getStore().load();\r
16 }\r
17 }, {\r
18 text: 'Explain',\r
19 handler: function() {\r
20 if (!this.explanation) {\r
21 this.explanation = Ext.create('Ext.Panel', {\r
22 modal: true,\r
23 hideOnMaskTap: true,\r
24 centered: true,\r
25 width: Ext.filterPlatform('ie10') ? '100%' : 320,\r
26 height: Ext.filterPlatform('ie10') ? '60%' : 200,\r
27 styleHtmlContent: true,\r
28 scrollable: true,\r
29 items: {\r
30 docked: 'top',\r
31 xtype: 'toolbar',\r
32 title: 'Loading Nested Data'\r
33 },\r
34 html: [\r
35 '<p>The data package can load deeply nested data in a single request. In this example we are loading a fictional',\r
36 'dataset containing Users, their Orders, and each Order\'s OrderItems.</p>',\r
37 '<p>Instead of pulling down each record in turn, we load the full data set in a single request and allow the data',\r
38 'package to automatically parse the nested data.</p>',\r
39 '<p>As one of the more complex examples, it is worth tapping the "Source" button to see how this is set up.</p>'\r
40 ].join("")\r
41 });\r
42 Ext.Viewport.add(this.explanation);\r
43 }\r
44 this.explanation.show();\r
45 }\r
46 }]\r
47 }, {\r
48 xtype: 'dataview',\r
49 id: 'NestedLoadingDataView',\r
50 emptyText: 'No Data Loaded',\r
51 styleHtmlContent: true,\r
52 /*\r
53 * The XTemplate allows us to easily render the data from our User model, as well as\r
54 * iterating over each User's Orders and OrderItems:\r
55 */\r
56 itemTpl: [\r
57 '<div class="user">',\r
58 '<h3>{name}\'s orders:</h3>',\r
59 '<tpl for="orders">',\r
60 '<div class="order" style="padding: 0 0 10px 20px;">',\r
61 'Order: {id} ({status})',\r
62 '<ul>',\r
63 '<tpl for="orderItems">',\r
64 '<li>{quantity} x {name}</li>',\r
65 '</tpl>',\r
66 '</ul>',\r
67 '</div>',\r
68 '</tpl>',\r
69 '</div>'\r
70 ].join(''),\r
71 store: {\r
72 model: 'User',\r
73 autoDestroy: true\r
74 }\r
75 }]\r
76});