隨筆-9  評論-168  文章-266  trackbacks-0
          一.JS文件
          var Employee = Ext.data.Record.create([
              {name: 'name', mapping: 'name'},     // "mapping" property not needed if it's the same as "name"
              {name: 'occupation'}                 // This field will use "occupation" as the mapping.
          ]);
          var myReader = new Ext.data.JsonReader({
              totalProperty: "results",    // The property which contains the total dataset size (optional)記錄總數(可選)
              root: "rows",                // The property which contains an Array of row objects 數組類型的行對象
              id: "id"                     // The property within each row object that provides an ID for the record (optional) 行對象里的主鍵(可選)
          }, Employee);

          二.JSP,PHP,ASP,ASP.NET等文件輸出內容
          { 'results': 2, 'rows': [ { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
              { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
          }


          三.JsonReader 構造函數
          JsonReader(
          jsonData : Object    After any data loads, the raw JSON data is available for further custom processing. If no data is loaded or there is a load exception this property will be undefined. 行數據

          meta : Mixed   This JsonReader's metadata as passed to the constructor, or as passed in the last data packet's MetaData property. 列數據



          樣例:
          var record=new Ext.data.Record({});   //必須添加{},且Ext.data.Record.creat({})設置后.   record.set(f.items.items[i].name,f.items.items[i].value) 報錯.
          record.set(f.items.items[i].name,f.items.items[i].value);
          Ext.Ajax.request({
                   params :record.data ,
                   url : "author_json1.faces",
                   waitMsg : '保存中,請稍后...',
                   success : function(re, v) {
                    f.ownerCt.close();// 沒有修改過則直接退出.
                    //var json = Ext.util.JSON.decode(v.response.responseText);
                    //author_store.loadData(json);
                    // Ext.Msg.alert("success!","add:"+json.author);
                    // 重新加載author tab內容.
                    // author_store.load({params:{webname:"findall"}});
                   },
                   failure : function() {
                    Ext.Msg.alert("", "failure!");
                   }
                  })
          posted on 2008-06-04 11:45 紫蝶∏飛揚↗ 閱讀(5584) 評論(2)  編輯  收藏 所屬分類: EXTJS

          評論:
          # re: EXTJS API JsonReader講解[未登錄] 2010-08-04 15:59 | 77
          7777  回復  更多評論
            
          # re: EXTJS API JsonReader講解 2010-08-31 16:16 | mrl
          有幫助!!!  回復  更多評論
            
          主站蜘蛛池模板: 同心县| 长垣县| 得荣县| 大安市| 昔阳县| 门头沟区| 湛江市| 黄石市| 香港| 潮安县| 新竹市| 石门县| 延川县| 尉犁县| 泸溪县| 永靖县| 吉木乃县| 大埔县| 涟源市| 景谷| 沾化县| 永春县| 土默特右旗| 城市| 边坝县| 凤庆县| 辉县市| 承德市| 江北区| 始兴县| 松溪县| 临猗县| 伽师县| 中宁县| 新竹县| 新乡县| 永康市| 浏阳市| 平定县| 日照市| 双流县|