隨筆-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
          有幫助!!!  回復  更多評論
            
          主站蜘蛛池模板: 太谷县| 阜新| 怀仁县| 靖边县| 江口县| 桂阳县| 江都市| 慈利县| 翁牛特旗| 洛阳市| 措勤县| 津南区| 香河县| 辽宁省| 岳西县| 灵璧县| 临海市| 安庆市| 南阳市| 沂源县| 廉江市| 泌阳县| 平顺县| 吴旗县| 从化市| 方正县| 榕江县| 平泉县| 屏东市| 遂川县| 新源县| 丰顺县| 曲沃县| 嘉黎县| 沧源| 托克托县| 淳安县| 哈尔滨市| 祁东县| 民丰县| 汽车|