Line | |
---|
1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | |
---|
8 | Ext.onReady(function(){ |
---|
9 | |
---|
10 | var store = new Ext.data.JsonStore({ |
---|
11 | url: 'get-images.php', |
---|
12 | root: 'images', |
---|
13 | fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}] |
---|
14 | }); |
---|
15 | store.load(); |
---|
16 | |
---|
17 | var listView = new Ext.ListView({ |
---|
18 | store: store, |
---|
19 | multiSelect: true, |
---|
20 | emptyText: 'No images to display', |
---|
21 | reserveScrollOffset: true, |
---|
22 | |
---|
23 | columns: [{ |
---|
24 | header: 'File', |
---|
25 | width: .5, |
---|
26 | dataIndex: 'name' |
---|
27 | },{ |
---|
28 | header: 'Last Modified', |
---|
29 | width: .35, |
---|
30 | dataIndex: 'lastmod', |
---|
31 | tpl: '{lastmod:date("m-d h:i a")}' |
---|
32 | },{ |
---|
33 | header: 'Size', |
---|
34 | dataIndex: 'size', |
---|
35 | tpl: '{size:fileSize}', |
---|
36 | align: 'right' |
---|
37 | }] |
---|
38 | }); |
---|
39 | |
---|
40 | // put it in a Panel so it looks pretty |
---|
41 | var panel = new Ext.Panel({ |
---|
42 | id:'images-view', |
---|
43 | width:425, |
---|
44 | height:250, |
---|
45 | collapsible:true, |
---|
46 | layout:'fit', |
---|
47 | title:'Simple ListView <i>(0 items selected)</i>', |
---|
48 | items: listView |
---|
49 | }); |
---|
50 | panel.render(document.body); |
---|
51 | |
---|
52 | // little bit of feedback |
---|
53 | listView.on('selectionchange', function(view, nodes){ |
---|
54 | var l = nodes.length; |
---|
55 | var s = l != 1 ? 's' : ''; |
---|
56 | panel.setTitle('Simple ListView <i>('+l+' item'+s+' selected)</i>'); |
---|
57 | }); |
---|
58 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.