posts - 241,  comments - 116,  trackbacks - 0
          以前一直是用jsonstore加載遠程數(shù)據(jù),最近要做combox加載webservice返回的本地數(shù)據(jù),進了誤區(qū)弄了好久,不過把store研究了下,自己做個記錄方便以后使用,也給遇到同樣問題的同學做個參考
          1.1:jsonstore加載遠程數(shù)據(jù):
          var dictComboBox = new Ext.form.ComboBox({
          fieldLabel:'證件類型',
          id:'idNoType',
          name:'dictType',
          readOnly:false,
          triggerAction:'all',
          editable:false,
          anchor:'90%',
          emptyText:'請選擇...',
          store:new Ext.data.JsonStore({
          url:this.basePath+'BasePackage/common_getSystemDictionaryItem?item_id=20003',
          fields:["dictValue","dictValueDesc"],
          root:'field1'       
          }),
          valueField:'dictValue',
          displayField:'dictValueDesc'
          });
          遠程返回數(shù)據(jù)格式:json
          {"field1":[{"dictValue":"","dictValueDesc",""},{"dictValue":"","dictValueDesc",""}]}
          最好加上editable:false,否則可以自己輸入,導致傳的數(shù)據(jù)格式出問題

          1.2:jsonstore加載本地數(shù)據(jù)
          var cardComboBox = new Ext.form.ComboBox({
          fieldLabel:'卡號',
          id:'oldCard',
          name:'dictType',
          readOnly:false,
          triggerAction:'all',
          editable:false,
          anchor:'90%',
          mode:'local',
          emptyText:'請選擇...',
          store:cardStore,
          displayField:'card_no'
          });
          var cardStore = new Ext.data.JsonStore({
          fields:['card_no'],
          root:'field1'
          });
          Ext.Ajax.request({url:...,
          params:{requesttype:"ajax"},
          jsonData:jsonString,
          callback:function (options, success, response) {
          if (success) {
          var jsonObj = Ext.util.JSON.decode(response.responseText);
          if (jsonObj.result) {
          var retField1 = jsonObj.field1;
          if(retField1.length == 0){
          ...
          return;
          }else{
          cardStore.loadData(jsonObj);
          }
          } else {GridView之CommandField的點擊提示刪除
              ...
          }
          } else {
          ...
          }
          }});
          ajax返回的json數(shù)據(jù)格式:
          {"result":true,"field1":[{"card_no":""},{"card_no":""}]}
          之前沒怎么看過combobox,combobox默認的讀取數(shù)據(jù)方式是遠程讀取,需要設url或proxy,沒設會一直包proxy對象為空,mode:'local'將combobox設置為讀取本地數(shù)據(jù)。
          posted on 2011-12-06 10:31 墻頭草 閱讀(2453) 評論(0)  編輯  收藏

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


          網站導航:
           
          人人游戲網 軟件開發(fā)網 貨運專家
          主站蜘蛛池模板: 新邵县| 介休市| 汶上县| 徐州市| 蒙自县| 永胜县| 伽师县| 大石桥市| 铁岭市| 澳门| 庐江县| 富源县| 马山县| 蚌埠市| 通州区| 来凤县| 建德市| 卓尼县| 建瓯市| 日喀则市| 汪清县| 息烽县| 嘉荫县| 白玉县| 南开区| 张家口市| 新巴尔虎右旗| 青冈县| 建德市| 马鞍山市| 马山县| 惠东县| 尼木县| 东源县| 紫金县| 建昌县| 金塔县| 津市市| 海兴县| 峨眉山市| 顺昌县|