posts - 241,  comments - 116,  trackbacks - 0
          以前一直是用jsonstore加載遠(yuǎn)程數(shù)據(jù),最近要做combox加載webservice返回的本地?cái)?shù)據(jù),進(jìn)了誤區(qū)弄了好久,不過把store研究了下,自己做個記錄方便以后使用,也給遇到同樣問題的同學(xué)做個參考
          1.1:jsonstore加載遠(yuǎn)程數(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'
          });
          遠(yuǎn)程返回?cái)?shù)據(jù)格式:json
          {"field1":[{"dictValue":"","dictValueDesc",""},{"dictValue":"","dictValueDesc",""}]}
          最好加上editable:false,否則可以自己輸入,導(dǎo)致傳的數(shù)據(jù)格式出問題

          1.2:jsonstore加載本地?cái)?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的點(diǎn)擊提示刪除
              ...
          }
          } else {
          ...
          }
          }});
          ajax返回的json數(shù)據(jù)格式:
          {"result":true,"field1":[{"card_no":""},{"card_no":""}]}
          之前沒怎么看過combobox,combobox默認(rèn)的讀取數(shù)據(jù)方式是遠(yuǎn)程讀取,需要設(shè)url或proxy,沒設(shè)會一直包proxy對象為空,mode:'local'將combobox設(shè)置為讀取本地?cái)?shù)據(jù)。
          posted on 2011-12-06 10:31 墻頭草 閱讀(2453) 評論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          人人游戲網(wǎng) 軟件開發(fā)網(wǎng) 貨運(yùn)專家
          主站蜘蛛池模板: 托克托县| 桂平市| 新化县| 平潭县| 镇坪县| 通州区| 余干县| 东乡县| 云梦县| 全椒县| 伊通| 达日县| 九寨沟县| 大悟县| 成安县| 鹤山市| 苍南县| 龙江县| 墨脱县| 涟水县| 嘉义县| 枣阳市| 太白县| 逊克县| 商城县| 静宁县| 额济纳旗| 宝丰县| 蒙自县| 凤翔县| 麦盖提县| 嘉荫县| 鞍山市| 烟台市| 孙吴县| 辽阳市| 吉木乃县| 绥芬河市| 廊坊市| 贡嘎县| 辰溪县|