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

          1.2:jsonstore加載本地數(shù)據
          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ù)據格式:
          {"result":true,"field1":[{"card_no":""},{"card_no":""}]}
          之前沒怎么看過combobox,combobox默認的讀取數(shù)據方式是遠程讀取,需要設url或proxy,沒設會一直包proxy對象為空,mode:'local'將combobox設置為讀取本地數(shù)據。
          posted on 2011-12-06 10:31 墻頭草 閱讀(2455) 評論(0)  編輯  收藏

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


          網站導航:
           
          人人游戲網 軟件開發(fā)網 貨運專家
          主站蜘蛛池模板: 桃园市| 沁水县| 普定县| 六安市| 外汇| 广汉市| 浪卡子县| 大丰市| 奉新县| 固始县| 万宁市| 桑日县| 双鸭山市| 随州市| 丹东市| 宽甸| 五常市| 河北省| 洱源县| 萍乡市| 司法| 察雅县| 临朐县| 汤原县| 清河县| 蓝山县| 葫芦岛市| 大渡口区| 桑植县| 贵南县| 抚松县| 那曲县| 张北县| 东阳市| 凤山县| 安龙县| 麻栗坡县| 革吉县| 阿坝| 疏附县| 石林|