-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
136 lines (136 loc) · 4.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Ext.require("Ext.MessageBox");
Ext.application({
name: 'PersonnelAttendanceSystem',
useLoadMask: true,
launch: function() {
// get the configuration for the list
var listConfiguration = this.getListConfiguration();
// if the device is not a phone, we want to create a centered panel and put the list
// into that
Ext.Viewport.add(listConfiguration);
// if (!Ext.os.is.Phone) {
// // use Ext.Viewport.add to add a new component into the viewport
// Ext.Viewport.add({
// // give it an xtype of panel
// xtype: 'panel',
// // give it a fixed witdh and height
// width: 350,
// height: 370,
// // make it centered
// centered: true,
// // make the component modal so there is a mask around the panel
// //modal: true,
// // set hideOnMaskTap to false so the panel does not hide when you tap on the mask
// //hideOnMaskTap: false,
// // give it a layout of fit so the list stretches to the size of this panel
// layout: 'fit',
// // insert the listConfiguration as an item into this panel
// items: [listConfiguration]
// });
// } else {
// // if we are a phone, simply add the list as an item to the viewport
// Ext.Viewport.add(listConfiguration);
// }
},
/**
* Returns a configuration object to be used when adding the list to the viewport.
*/
getListConfiguration: function() {
// create a store instance
var store = Ext.create('Ext.data.Store', {
// give the store some fields
fields: ['noteTitle', 'noteDes'],
// filter the data using the firstName field
sorters: [{
property: "noteTitle",
direction: "ASC"
}],
// autoload the data from the server
autoLoad: true,
// setup the grouping functionality to group by the first letter of the firstName field
grouper: {
groupFn: function(record) {
return record.get('noteTitle');
}
},
// setup the proxy for the store to use an ajax proxy and give it a url to load
// the local contacts.json file
proxy: {
type: 'ajax',
url: 'test.json',
reader: Ext.create('Ext.data.reader.Json', {
type: 'json',
rootProperty: 'data',
totalProperty: 'totalCount',
successProperty: 'success'
}),
simpleSortMode: true
}
});
return Ext.create('Ext.List', {
fullscreen: true,
itemTpl: '{noteTitle} {noteDes}',
disclosure: true,
// group the list
grouped: true,
// enable the indexBar
// indexBar: {
// listPrefix: '#',
// listeners: {
// index: function(inBar, html, target, eOpts) {
// //console.log(inBar);
// //console.log(html);
// //console.log(target);
// }
// }
// },
infinite: true,
useSimpleItems: true,
variableHeights: true,
striped: true,
// ui: 'round',
plugins: [{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}, {
xclass: 'Ext.plugin.PullRefresh',
pullRefreshText: '下拉可以更新',
releaseRefreshText: '松开开始更新',
loading: '正在刷新……',
refreshFn: function(loaded, arguments) {
console.log(loaded);
loaded.getList().getStore().getProxy().setExtraParam('q', '参数'); // 设置proxy参数
loaded.getList().getStore().loadPage(1, {
callback: function(record, operation, success) {
Ext.Viewport.unmask();
},
scope: this
});
}
}],
// set the function when a user taps on a disclsoure icon
onItemDisclosure: function(record, item, index, e) {
// show a messagebox alert which shows the persons firstName
e.stopEvent();
Ext.Msg.alert('Disclose', 'Disclose more info for ' + record.get('noteTitle'));
},
// bind the store to this list
store: store,
grouped: true,
emptyText: '<div style="margin-top: 20px; text-align: center">No Matching Items</div>',
disableSelection: true,
items: [{
xtype: 'toolbar',
docked: 'top',
items: [{
xtype: 'spacer'
}, {
xtype: 'searchfield',
placeHolder: 'Search...'
}, {
xtype: 'spacer'
}]
}]
});
}
})