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
| Ext.require([
| 'Ext.grid.*',
| 'Ext.data.*',
| 'Ext.panel.*'
| ]);
| Ext.onReady(function(){
| Ext.define('ImageModel', {
| extend: 'Ext.data.Model',
| fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}]
| });
| var store = Ext.create('Ext.data.JsonStore', {
| model: 'ImageModel',
| proxy: {
| type: 'ajax',
| url: 'get-images.php',
| reader: {
| type: 'json',
| root: 'images'
| }
| }
| });
| store.load();
|
| var listView = Ext.create('Ext.grid.Panel', {
| width:425,
| height:250,
| collapsible:true,
| title:'Simple ListView <i>(0 items selected)</i>',
| renderTo: Ext.getBody(),
|
| store: store,
| multiSelect: true,
| viewConfig: {
| emptyText: 'No images to display'
| },
|
| columns: [{
| text: 'File',
| flex: 50,
| dataIndex: 'name'
| },{
| text: 'Last Modified',
| xtype: 'datecolumn',
| format: 'm-d h:i a',
| flex: 35,
| dataIndex: 'lastmod'
| },{
| text: 'Size',
| dataIndex: 'size',
| tpl: '{size:fileSize}',
| align: 'right',
| flex: 15,
| cls: 'listview-filesize'
| }]
| });
|
| // little bit of feedback
| listView.on('selectionchange', function(view, nodes){
| var len = nodes.length,
| suffix = len === 1 ? '' : 's',
| str = 'Simple ListView <i>({0} item{1} selected)</i>';
|
| listView.setTitle(Ext.String.format(str, len, suffix));
| });
| });
|
|