ExtJS 구성 요소 - store ①

2479 단어 ext
Ext.onReady(function(){
	
	Ext.BLANK_IMAGE_URL = '../ext-2.2/resources/images/default/s.gif';
	
    var cm = new Ext.grid.ColumnModel([
        {header:' ',dataIndex:'id',sortable:true},
        {header:' ',dataIndex:'name',width:80},
        {id:'descn',header:' ',dataIndex:'descn'},
        {header:' ',dataIndex:'date', renderer: Ext.util.Format.dateRenderer('Y-m-d')}
    ]);

    var data = [
        ['1','name1','descn1','1970-01-15T02:58:04'],
        ['2','name2','descn2','1970-01-15T02:58:04'],
        ['3','name3','descn3','1970-01-15T02:58:04'],
        ['4','name4','descn4','1970-01-15T02:58:04'],
        ['5','name5','descn5','1970-01-15T02:58:04']
    ];

    var store = new Ext.data.Store({
        proxy: new Ext.data.MemoryProxy(data),
        reader: new Ext.data.ArrayReader(
	        {},
	        [
	            {name: 'id'},
	            {name: 'name'},
	            {name: 'descn'},
	            {name: 'date', type:'date',dateFormat: 'Y-m-dTH:i:s'}
	        ])
//	        ,sortInfo:{field:'id',direction: 'DESC'}// 
    });
    store.load();

    var grid = new Ext.grid.GridPanel({
        autoHeight: true,
        renderTo: 'grid',
        store: store,
        cm: cm,
//        autoExpandColumn:'descn'// id,grid , 
        stripeRows: true, //  
        viewConfig: {
            forceFit: true
        } // 
        ,animCollapse:true
    });
    
   /** //   store
    for(var i=0;i<store.getCount();i++){
    	alert('store for:'+store.getAt(i).get('name'));
    }
    store.each(function(record){
    	alert('store.each:'+record.get('name'));
    });
//    
    var record = store.getRange(0,2);
    for(var i=0;i<record.length;i++){
    	alert(' :'+record[i].get('name'));
    }
    **/
});






좋은 웹페이지 즐겨찾기