---
title: "gird 翻页"
author: "sailei1"
date: "2013-05-15T14:57:10Z"
tags: []
categories: ["移动开发"]
slug: "gird"
draft: false
lastmod: "2013-05-15T14:57:10Z"
id: 1869770
url: "https://sailei1.iteye.com/blog/1869770"
---

```js


//<debug>
Ext.Loader.setPath({
    'Ext': 'touch/src',
    'room': 'app',
    'Ext.ux.touch.grid': 'Ext.ux.touch.grid'
});
//</debug>

Ext.require([
             'ext.ux.touch.grid.list',
             'ext.ux.touch.grid.feature.feature',
             'ext.ux.touch.grid.feature.sorter'
         ]);

Ext.application({
    name: 'room',

    requires: [
        'ext.messagebox',
        'ext.carousel.carousel'
    ],

    models:[
    ],

    views: [
            ],

    stores: [
    ],

    controllers: [
                  'main'
    ],
    
    icon: {
        '57': 'resources/icons/Icon.png',
        '72': 'resources/icons/Icon~ipad.png',
        '114': 'resources/icons/Icon@2x.png',
        '144': 'resources/icons/Icon~ipad@2x.png'
    },

    isIconPrecomposed: true,

    startupImage: {
        '320x460': 'resources/startup/320x460.jpg',
        '640x920': 'resources/startup/640x920.png',
        '768x1004': 'resources/startup/768x1004.png',
        '748x1024': 'resources/startup/748x1024.png',
        '1536x2008': 'resources/startup/1536x2008.png',
        '1496x2048': 'resources/startup/1496x2048.png'
    },

    launch: function() {
        // Destroy the #appLoadingIndicator element
        Ext.fly('appLoadingIndicator').destroy();

        // Initialize the main view
      //  Ext.Viewport.add(Ext.create('room.view.Main'));
        
        
        Ext.define('TestModel', {
            extend : 'Ext.data.Model',

            config : {
                fields : [
                    'company',
                    'price',
                    'change',
                    'pct',
                    'updated'
                ]
            }
        });

        var store = Ext.create('Ext.data.Store', {
            model   : 'TestModel',
            data    : [
                { company : '3m co',                               price : 71.72, change : 0.02,  pct : 0.03,  updated : '9/1/2010' },
                { company : 'alcoa inc',                           price : 29.01, change : 0.42,  pct : 1.47,  updated : '9/1/2010' },
                { company : 'altria group inc',                    price : 83.81, change : 0.28,  pct : 0.34,  updated : '9/1/2010' },
                { company : 'american express company',            price : 52.55, change : 0.01,  pct : 0.02,  updated : '9/1/2010' },
                { company : 'american international group, inc.',  price : 64.13, change : 0.31,  pct : 0.49,  updated : '9/1/2010' },
                { company : 'at&#38;t inc.',                       price : 31.61, change : -0.48, pct : -1.54, updated : '9/1/2010' },
                { company : 'boeing co.',                          price : 75.43, change : 0.53,  pct : 0.71,  updated : '9/1/2010' },
                { company : 'caterpillar inc.',                    price : 67.27, change : 0.92,  pct : 1.39,  updated : '9/1/2010' },
                { company : 'citigroup, inc.',                     price : 49.37, change : 0.02,  pct : 0.04,  updated : '9/1/2010' },
                { company : 'e.i. du pont de nemours and company', price : 40.48, change : 0.51,  pct : 1.28,  updated : '9/1/2010' },
                { company : 'exxon mobil corp',                    price : 68.1,  change : -0.43, pct : -0.64, updated : '9/1/2010' },
                { company : 'general electric company',            price : 34.14, change : -0.08, pct : -0.23, updated : '9/1/2010' },
                { company : 'general motors corporation',          price : 30.27, change : 1.09,  pct : 3.74,  updated : '9/1/2010' },
                { company : 'hewlett-packard co.',                 price : 36.53, change : -0.03, pct : -0.08, updated : '9/1/2010' },
                { company : 'honeywell intl inc',                  price : 38.77, change : 0.05,  pct : 0.13,  updated : '9/1/2010' },
                { company : 'intel corporation',                   price : 19.88, change : 0.31,  pct : 1.58,  updated : '9/1/2010' },
                { company : 'international business machines',     price : 81.41, change : 0.44,  pct : 0.54,  updated : '9/1/2010' },
                { company : 'johnson &#38; johnson',               price : 64.72, change : 0.06,  pct : 0.09,  updated : '9/1/2010' },
                { company : 'jp morgan &#38; chase &#38; co',      price : 45.73, change : 0.07,  pct : 0.15,  updated : '9/1/2010' },
                { company : 'mcdonald\'s corporation',             price : 36.76, change : 0.86,  pct : 2.40,  updated : '9/1/2010' },
                { company : 'merck &#38; co., inc.',               price : 40.96, change : 0.41,  pct : 1.01,  updated : '9/1/2010' },
                { company : 'microsoft corporation',               price : 25.84, change : 0.14,  pct : 0.54,  updated : '9/1/2010' },
                { company : 'pfizer inc',                          price : 27.96, change : 0.4,   pct : 1.45,  updated : '9/1/2010' },
                { company : 'the coca-cola company',               price : 45.07, change : 0.26,  pct : 0.58,  updated : '9/1/2010' },
                { company : 'the home depot, inc.',                price : 34.64, change : 0.35,  pct : 1.02,  updated : '9/1/2010' },
                { company : 'the procter &#38; gamble company',    price : 61.91, change : 0.01,  pct : 0.02,  updated : '9/1/2010' },
                { company : 'united technologies corporation',     price : 63.26, change : 0.55,  pct : 0.88,  updated : '9/1/2010' },
                { company : 'verizon communications',              price : 35.57, change : 0.39,  pct : 1.11,  updated : '9/1/2010' },
                { company : 'wal-mart stores, inc.',               price : 45.45, change : 0.73,  pct : 1.63,  updated : '9/1/2010' }
            ]
        });

        var gird= Ext.create('Ext.ux.touch.grid.List', {
            store      : store,
             id:'grid',
             scrollable: {
        	    direction: 'vertical',
        	    directionLock: true
        	},
              columns    : [
            
                {
                    header    : 'price',
                    dataindex : 'price',
                    style     : 'text-align: center;',
                    width     : '15%'
                },
                {
                    header    : 'change',
                    dataindex : 'change',
                    cls       : 'centered-cell',
                    width     : '15%'
                },
               
            ],
            listeners:{
		initialize:function(list){
		 
		    var  s=  list.getScrollable().getScroller();
			   s.on('scroll',function(s,x,y,eOpts){
				   var gs=  Ext.getCmp('list').getScrollable().getScroller();
				   gs.scrollTo(x,y);
				});
		}
	    } 

        });
        
        var gird1= Ext.create('Ext.ux.touch.grid.List', {
            store      : store,
            columns    : [
                 {
                    header    : '% change',
                    dataindex : 'pct',
                    cls       : 'centered-cell',
                    width     : '15%'
                },
                {
                    header    : '% change2',
                    dataindex : 'pct',
                    cls       : 'centered-cell',
                    width     : '15%'
                },
                {
                    header    : 'last updated',
                    dataindex : 'updated',
                    hidden    : true,
                    style     : 'text-align: right; padding-right: 1em;',
                    width     : '15%'
                }
                
            ],
            listeners:{
		initialize:function(list){
		 
		    var  s=  list.getScrollable().getScroller();
			   s.on('scroll',function(s,x,y,eOpts){
				   var gs=  Ext.getCmp('list').getScrollable().getScroller();
				   gs.scrollTo(x,y);
				});
		}
	    } 

        });
        
      var c=  Ext.create('Ext.Carousel', {
           
            indicator: false,
            //fullscreen:true,
            items: [
                    gird,
                    gird1
                
            ],
            listeners:{
            activeitemchange:function(c,v,old,eOpts){
        	 Ext.getCmp('list').getScrollable().getScroller().scrollTo(0,0);
        	
        	
            }
            }
        });

     
     var list=Ext.create('Ext.List', {
	   	id:'list',
	    itemTpl: '{company}',
	    store      : store,
	    scrollable :false,
	   
	});
     
    
     Ext.Viewport.add( Ext.create('Ext.Panel', {
	  layout: 'hbox',
	
	  height:'1000',
	  items:[ {
	            xtype: 'panel',
	           
	            layout: 'fit',
	            items:[{xtype:'titlebar',docked:'top',cls    : 'x-grid-header',title:'company'},
	                   list],
	            flex: 1
	        },
	        {
	            xtype: 'panel',
	            id:'panel2',
	            layout: 'fit',
	  	    items: [c],
	            flex: 3
	        }]
      }));
        
        
    },

    onUpdated: function() {
        Ext.Msg.confirm(
            "Application Update",
            "This application has just successfully been updated to the latest version. Reload now?",
            function(buttonId) {
                if (buttonId === 'yes') {
                    window.location.reload();
                }
            }
        );
    }
});


```