孤燈野火
          暢想的天空
          posts - 2,comments - 4,trackbacks - 0


          /*
           * Ext JS Library 2.2.1
           * Copyright(c) 2006-2009, Ext JS, LLC.
           * licensing@extjs.com
           *
           * http://extjs.com/license
           */

          Ext.onReady(function(){

              // NOTE: This is an example showing simple state management. During development,
              // it is generally best to disable state management as dynamically-generated ids
              // can change across page loads, leading to unpredictable results.  The developer
              // should ensure that stable state ids are set for stateful components in real apps.
              Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

           var store=new Ext.data.JsonStore({
            
              //results 表示結(jié)果數(shù)
              //rows 表示從后臺(tái)傳過來的JSON數(shù)據(jù)
              data:{ "results": 2, "rows":[
                  {"id":1, "city": "suzhou", "areacode": "0512", "perincome": "2500" },
                  {"id":2, "city": "nanjing", "areacode": "025", "perincome": "2200" }]},

                 //自動(dòng)加載(不能用store.load())
              autoLoad:true,
              totalProperty:"results",

              root:"rows",

              fields:['title',  {name:'city',mapping:'city'},

              {name:'areacode',type:'int'},

              {name:'perincome',mapping:'perincome',type:'int'},

              {name:'id',mapping:'id',type:'int'}

              ]

            });

             

              // create the Grid
              var grid = new Ext.grid.GridPanel({
                  store: store,
                  columns: [
                     {id:'city',header: "city", width: 400, sortable: true, dataIndex: 'city'},
                      {header: "areacode", width: 200, sortable: true, dataIndex: 'areacode'},
                      {header: "perincome", width: 200, sortable: true, dataIndex: 'perincome'}
                  ],
                  stripeRows: true,
                  autoExpandColumn: 'city',
                  height:280,
                  width:600,
                  title:'Array Grid'
             });

           grid.on('rowclick', function(grid, rowIndex, e) {
                 var recordr = store.getAt(rowIndex);
                 alert('id is ' + recordr.get('id') + ',city name is ' + recordr.get('city'));
                // window.open('index.html');//設(shè)置轉(zhuǎn)向地址,用于對(duì)row的操作,舉個(gè)例子 當(dāng)然也可以用location.href等
               });  

           //把此grid放進(jìn)grid-example里面
              grid.render('grid-example');
          });

           

           


           

          posted on 2010-08-27 14:37 孤飛燕 閱讀(2105) 評(píng)論(0)  編輯  收藏 所屬分類: Ext

          只有注冊用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 苍山县| 海林市| 潼南县| 肃南| 南投县| 罗田县| 闽侯县| 乐业县| 米脂县| 临猗县| 宝坻区| 罗城| 房山区| 林芝县| 香格里拉县| 唐河县| 叙永县| 宁阳县| 苏尼特左旗| 嘉善县| 故城县| 红河县| 五指山市| 木兰县| 庄浪县| 泰安市| 西和县| 桦南县| 裕民县| 萝北县| 桐柏县| 富宁县| 藁城市| 东辽县| 清流县| 建湖县| 溧阳市| 郸城县| 长寿区| 咸宁市| 安阳市|