饼子天空  
个人程序Blogs

 

1:转:紫蝶∏飛揚↗

 //consume JSON of this form:

{
   
"images":[
      
{
         
"name":"dance_fever.jpg",
         
"size":2067,
         
"lastmod":1236974993000,
         
"url":"images\/thumbs\/dance_fever.jpg"
      }
,
      
{
         
"name":"zack_sink.jpg",
         
"size":2303,
         
"lastmod":1236974993000,
         
"url":"images\/thumbs\/zack_sink.jpg"
      }

   ]
}
 
var store 
= new Ext.data.JsonStore({
    url: 
'get-images.php',
    root: 
'images',
    fields: [
        
'name''url',
        
{name:'size', type: 'float'},
        
{name:'lastmod', type:'date', dateFormat:'timestamp'}
    ]
}
);
store.load();

var listView 
= new Ext.ListView({
    store: store,
    multiSelect: 
true,
    emptyText: 
'No images to display',
    reserveScrollOffset: 
true,
    columns: [
{
        header: 
'File',
        width: .
5,
        dataIndex: 
'name'
    }
,{
        header: 
'Last Modified',
        width: .
35
        dataIndex: 
'lastmod',
        tpl: 
'{lastmod:date("m-d h:i a")}'
    }
,{
        header: 
'Size',
        dataIndex: 
'size',
        tpl: 
'{size:fileSize}'// format using Ext.util.Format.fileSize()

        align: 
'right'
    }
]
}
);

// put it in a Panel so it looks pretty

var panel 
= new Ext.Panel({
    id:
'images-view',
    width:
425,
    height:
250,
    collapsible:
true,
    layout:
'fit',
    title:
'Simple ListView (0 items selected)',
    items: listView
}
);
panel.render(document.body);

// little bit of feedback

listView.on(
'selectionchange', function(view, nodes){
    var l 
= nodes.length;
    var s 
= l != 1 ? 's' : '';
    panel.setTitle(
'Simple ListView ('+l+' item'+s+' selected)');
}
);

 

 

转: mysouling

  1. ////////////////////////////////////////////////////////////////  
  2. // 功能名称:LISTVIEW  
  3. // 功能说明:LISTVIEW  
  4. // 调用xtype: 'complistview',  
  5. //     store: [[1, 'One'], [2, 'Two'], [3, 'Three']],  
  6. // 创 建 人:mysoul  
  7. // 创建时间:2010-03-18  
  8. ////////////////////////////////////////////////////////////////      
  9.   
  10. Euroa.component.ComponentListView = Ext.extend(Ext.ListView, {  
  11.     defaultType: 'textfield',  
  12.     initComponent : function(){  
  13.         Ext.ux.ComponentListView.superclass.initComponent.call(this);  
  14.         this.components = [];  
  15.     },  
  16.     refresh : function(){  
  17.         Ext.destroy(this.components);  
  18.         this.components = [];  
  19.         Ext.ux.ComponentListView.superclass.refresh.apply(this, arguments);  
  20.         this.renderItems(0, this.store.getCount() - 1);  
  21.     },  
  22.     onUpdate : function(ds, record){  
  23.         var index = ds.indexOf(record);  
  24.         if(index > -1){  
  25.             this.destroyItems(index);  
  26.         }  
  27.         Ext.ux.ComponentListView.superclass.onUpdate.apply(this, arguments);  
  28.         if(index > -1){  
  29.             this.renderItems(index, index);  
  30.         }  
  31.     },  
  32.     onAdd : function(ds, records, index){  
  33.         
posted on 2010-10-13 23:05  饼子天空  阅读(2171)  评论(0)    收藏  举报