forked from mitchellsimoens/Ext.ux.touch.grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infinite.js
116 lines (110 loc) · 3.56 KB
/
infinite.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
Ext.Loader.setConfig({
enabled : true,
paths : {
'Ext.ux.touch.grid': './Ext.ux.touch.grid'
}
});
Ext.require([
'Ext.data.proxy.JsonP',
'Ext.ux.touch.grid.List',
'Ext.ux.touch.grid.feature.Feature',
'Ext.ux.touch.grid.feature.Sorter'
]);
Ext.define('ForumThread', {
extend : 'Ext.data.Model',
config : {
idProperty : 'threadid',
fields : [
'title',
'forumtitle',
'forumid',
'username',
'lastposter',
'excerpt',
'threadid',
{
name : 'replycount',
type : 'int'
},
{
name : 'lastpost',
mapping : 'lastpost',
type : 'date',
dateFormat : 'timestamp'
}
]
}
});
Ext.setup({
onReady: function() {
var store = Ext.create('Ext.data.Store', {
model : 'ForumThread',
autoLoad : true,
remoteGroup : true,
pageSize : 1000,
proxy : {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an Ajax proxy would be better
type : 'jsonp',
url : 'http://www.sencha.com/forum/remote_topics/index.php',
reader : {
rootProperty : 'topics',
totalProperty : 'totalCount'
},
// sends single sort as multi parameter
simpleSortMode : true,
// sends single group as multi parameter
simpleGroupMode : true,
// This particular service cannot sort on more than one field, so grouping === sorting.
groupParam : 'sort',
groupDirectionParam : 'dir'
},
sorters : [
{
property : 'threadid',
direction : 'ASC'
}
]
});
Ext.create('Ext.ux.touch.grid.List', {
fullscreen : true,
store : store,
infinite : true,
columns : [
{
header : 'Title',
dataIndex : 'title',
style : 'padding-left: 1em;',
width : '40%'
},
{
header : 'User',
dataIndex : 'username',
style : 'text-align: center;',
width : '15%'
},
{
header : 'Forum',
dataIndex : 'forumtitle',
style : 'text-align: center;',
width : '15%'
},
{
header : 'Replies',
dataIndex : 'replycount',
style : 'text-align: center;',
width : '15%'
},
{
header : 'Last Post',
dataIndex : 'lastpost',
style : 'text-align: right; padding-right: 1em;',
width : '15%',
renderer : function(date) {
return Ext.Date.format(date, 'M j Y g:ia');
}
}
]
});
}
});