This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
meta.js
99 lines (84 loc) · 2.19 KB
/
meta.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
Ext.Loader.setConfig({
paths : {
'Ext.ux.touch.grid' : './Ext.ux.touch.grid'
}
});
Ext.require([
'Ext.ux.touch.grid.List',
'Ext.ux.touch.grid.feature.Feature',
'Ext.ux.touch.grid.feature.Sorter'
]);
Ext.define('Ux.data.reader.ColJson', {
extend : 'Ext.data.reader.Json',
alias : 'reader.coljson',
config : {
columnProperty : 'columns'
},
/**
* @private
*/
columnAccessor : null,
buildExtractors : function() {
this.callParent(arguments);
var columnProp = this.getColumnProperty();
if (columnProp) {
this.columnAccessor = this.createAccessor(columnProp);
}
},
getColumns : function() {
var accessor = this.columnAccessor,
rawData = this.rawData;
return accessor(rawData);
}
});
Ext.define('TestModel', {
extend : 'Ext.data.Model',
config : {
fields : [
'company',
'price',
'change',
'pct',
'updated'
],
proxy : {
type : 'ajax',
url : 'meta.php',
reader : {
type : 'coljson',
rootProperty : 'data',
columnProperty : 'columns'
},
extraParams : {
sleep : 2
}
}
}
});
Ext.setup({
onReady : function () {
var store = Ext.create('Ext.data.Store', {
autoLoad : true,
model : 'TestModel',
pageSize : 5,
listeners : {
load : function(store) {
var proxy = store.getProxy(),
reader = proxy.getReader(),
columns = reader.getColumns();
grid.setColumns(columns);
}
}
});
var grid = Ext.create('Ext.ux.touch.grid.List', {
fullscreen : true,
store : store,
features : [
{
ftype : 'Ext.ux.touch.grid.feature.Sorter',
launchFn : 'initialize'
}
]
});
}
});