Ext4.2 沒提供proxy代理 動態生成checkbox html
現記錄實現辦法 json
ids:回顯數據時,要顯示勾選Chekbox的值 api
flag:是否可修改,true不可修改 ,false爲可修改 async
name:每一個checkbox的name url
返回數據即爲checkbox的json格式數據 代理
function getAccountType(ids,flag,name){ //flag 爲true不可修改 var data; Ext.Ajax.request({ url : 'brokersDownload/brokerBasicInfo.jhtml?type=getAccountType', async:false, success : function(response, action){ if(response.responseText != ""){ data = Ext.decode(response.responseText); }else{ Ext.MessageBox.alert('提示', '找不到帳戶類型!'); } }, failure : function(form, action){ Ext.MessageBox.alert('提示', '找不到帳戶類型!'); } }) return formatData(ids,data,flag,'accountType'); } function formatData(ids,data,flag,name){ var arr = [] for(var i = 0;i < data.length; i ++){ arr.push({boxLabel:data[i].boxLabel,inputValue:data[i].inputValue,name:name}) if(flag){ arr[i].readOnly = true; } } if(ids != null){ for( i in ids){ for(j in arr){ if(ids[i] == arr[j].inputValue){ arr[j].checked = true; } } } } return arr; }
原來api中有解決方案setValue,本身實現一遍也是真傻 code