]>
git.proxmox.com Git - sencha-touch.git/blob - src/examples/list/app.js
8 * This simple example shows the ability of the Ext.List component.
10 * In this example, it uses a grouped store to show group headers in the list. It also
11 * includes an indicator so you can quickly swipe through each of the groups. On top of that
12 * it has a disclosure button so you can disclose more information for a list item.
15 //define the application
17 //define the startupscreens for tablet and phone, as well as the icon
19 '320x460': 'resources/startup/Default.jpg', // Non-retina iPhone, iPod touch, and all Android devices
20 '640x920': 'resources/startup/640x920.png', // Retina iPhone and iPod touch
21 '640x1096': 'resources/startup/640x1096.png', // iPhone 5 and iPod touch (fifth generation)
22 '768x1004': 'resources/startup/768x1004.png', // Non-retina iPad (first and second generation) in portrait orientation
23 '748x1024': 'resources/startup/748x1024.png', // Non-retina iPad (first and second generation) in landscape orientation
24 '1536x2008': 'resources/startup/1536x2008.png', // : Retina iPad (third generation) in portrait orientation
25 '1496x2048': 'resources/startup/1496x2048.png' // : Retina iPad (third generation) in landscape orientation
28 isIconPrecomposed
: false,
30 57: 'resources/icons/icon.png',
31 72: 'resources/icons/icon@72.png',
32 114: 'resources/icons/icon@2x.png',
33 144: 'resources/icons/icon@144.png'
36 //require any components/classes what we will use in our example
41 'Ext.plugin.PullRefresh'
45 * The launch method is called when the browser is ready, and the application can launch.
47 * Inside our launch method we create the list and show in in the viewport. We get the lists configuration
48 * using the getListConfiguration method which we defined below.
50 * If the user is not on a phone, we wrap the list inside a panel which is centered on the page.
53 //get the configuration for the list
54 var listConfiguration
= this.getListConfiguration();
56 //if the device is not a phone, we want to create a centered panel and put the list
58 if (!Ext
.os
.is
.Phone
) {
59 //use Ext.Viewport.add to add a new component into the viewport
61 //give it an xtype of panel
64 //give it a fixed witdh and height
71 //make the component modal so there is a mask around the panel
74 //set hideOnMaskTap to false so the panel does not hide when you tap on the mask
77 //give it a layout of fit so the list stretches to the size of this panel
80 //insert the listConfiguration as an item into this panel
81 items
: [listConfiguration
]
84 //if we are a phone, simply add the list as an item to the viewport
85 Ext
.Viewport
.add(listConfiguration
);
90 * Returns a configuration object to be used when adding the list to the viewport.
92 getListConfiguration: function() {
93 //create a store instance
94 var store
= Ext
.create('Ext.data.Store', {
95 //give the store some fields
96 fields
: ['firstName', 'lastName'],
98 //filter the data using the firstName field
101 //autoload the data from the server
104 //setup the grouping functionality to group by the first letter of the firstName field
106 groupFn: function(record
) {
107 return record
.get('firstName')[0];
111 //setup the proxy for the store to use an ajax proxy and give it a url to load
112 //the local contacts.json file
120 //give it an xtype of list for the list component
129 //set the itemtpl to show the fields for the store
130 itemTpl
: '{firstName} {lastName}',
132 //enable disclosure icons
138 //enable the indexBar
143 useSimpleItems
: true,
145 variableHeights
: true,
151 //set the function when a user taps on a disclsoure icon
152 // onItemDisclosure: function(record, item, index, e) {
153 // //show a messagebox alert which shows the persons firstName
155 // Ext.Msg.alert('Disclose', 'Disclose more info for ' + record.get('firstName'));
158 //bind the store to this list