把数据转成JSON 数据
private
String getCurrencyAccountJson(Map<String, List<CrdCurrentAcctMaster>> accountCCY){
Set<String> set = accountCCY.keySet();new JSONObject(); JSONObject jsonObj =for (String str : set) { List<CrdCurrentAcctMaster> reportTypeList = accountCCY.get(str); JSONObject typeJson =new JSONObject();for (int i=0; i<reportTypeList.size();i++){ CrdCurrentAcctMaster reportType = reportTypeList.get(i); typeJson.put(i,reportType.getAcctCcy()+"_"+reportType.getAcctNum()); } jsonObj.put(str, typeJson); }return jsonObj.toString();
JS 函数控制显示:
function showAccoutNum(){var accountccy = $.parseJSON('${accountCurrencyList}');
var oneOffValuationDate = $("#oneOffValuationDate").val();var createType = $("#createType").val();if(oneOffValuationDate == ""){ $("#accountCurrency option").each(function(i){ $(this).remove(); }); $("#accountCurrency").append("<option value=''>ALL</option>");return ; }else{//alert("oneOffValuationDate="+oneOffValuationDate);//remove the old $("#accountCurrency option").each(function(i){ $(this).remove(); }); $("#accountCurrency").append("<option value=''>ALL</option>");if (accountccy[oneOffValuationDate] == undefined){ alert("this one-off valueation Date have no account num and ccy!");return false; }//append the newfor(var i=0;1;i++){// ccyacount = ccy_numvar ccyaccount = accountccy[oneOffValuationDate][i];//alert(ccyaccount);if ( ccyaccount == undefined){break; }var arrayCCY = ccyaccount.split("_");//alert(arrayCCY[0]+"---"+arrayCCY[1]);if (createType == 'edit' || createType == 'exist'){var accNum = $("#accountNum").val();if (accNum.indexOf(arrayCCY[1]) != -1){ $("#accountCurrency").append("<option value='"+arrayCCY[1]+"' currencyValue='"+accountccy[oneOffValuationDate]+"' selected>"+ccyaccount+"</option>"); } }else{ $("#accountCurrency").append("<option value='"+arrayCCY[1]+"' currencyValue='"+accountccy[oneOffValuationDate]+"'>"+ccyaccount+"</option>"); } } }}