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