vickzhu

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            151 隨筆 :: 0 文章 :: 34 評論 :: 0 Trackbacks
          Ext的數據存儲器為:Ext.data.Store
          ExtJS中有一個名為Record的類,表格等控件中使用的數據是存放在Record對象中,一個Record可以理解為關系數據表中的一行,也可以稱為記錄。Record對象中即包含了記錄(行中各列)的定義信息(也就是該記錄包含哪些字段,每一個字段的數據類型等),同時又包含了記錄具體的數據信息(也就是各個字段的值)。一個比較正規的創建store的代碼如下:
          var MyRecord = Ext.data.Record.create([
           {name: 'title'},
           {name: 'username', mapping: 'author'},
           {name: 'loginTimes', type: 'int'},
           {name: 'lastLoginTime', mapping: 'loginTime', type: 'date'}
          ]);
          var dataProxy=new Ext.data.HttpProxy({url:"login.do"});
          var theReader=new Ext.data.JsonReader({
           totalProperty: "results", 
           root: "rows",             
           id: "id"                  
           },MyRecord
          );
          var store=new Ext.data.Store({  
           proxy:dataProxy,
           reader:theReader
          });
          store.load();
          store在創建的時候會自動使用HttpProxy來加載參數,并且使用post方式來提交請求,因此上面的代碼可簡化為:
          var MyRecord = Ext.data.Record.create([
           {name: 'title'},
           {name: 'username', mapping: 'author'},
           {name: 'loginTimes', type: 'int'},
           {name: 'lastLoginTime', mapping: 'loginTime', type: 'date'}
          ]);
          var theReader=new Ext.data.JsonReader({
           totalProperty: "results", 
           root: "rows",             
           id: "id"                  
           },MyRecord
          );
          var store=new Ext.data.Store({  
          url:'login.do',
           reader:theReader
          });
          store.load();
          在Store類的基礎上提供了SimpleStore、JSonStore、GroupingStore等,因此上面的JsonReader可以省略:
          var store = new Ext.data.JsonStore({
                      url:'contact.do',
                      root:'data',
                      totalProperty:'totalCount',
                      fields:[{name: 'vid', mapping: 'id'},
                          {name: 'name', mapping: 'name'},
                          {name: 'vmethod', mapping: 'vmethod'}]
                  });
          posted on 2009-05-22 11:15 筱 筱 閱讀(754) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 张北县| 吕梁市| 甘南县| 固镇县| 太谷县| 泽州县| 广安市| 特克斯县| 江陵县| 和静县| 湾仔区| 房山区| 黄骅市| 瑞安市| 静安区| 乌拉特前旗| 连江县| 蛟河市| 昔阳县| 任丘市| 儋州市| 仙桃市| 长汀县| 苏尼特左旗| 抚顺县| 甘洛县| 仙居县| 石阡县| 绥滨县| 桂阳县| 新巴尔虎左旗| 台南市| 南通市| 湟源县| 泰顺县| 常德市| 清涧县| 察雅县| 清原| 呼和浩特市| 花垣县|