当前位置:首页 » JavaScript技术

js前端解析后台代码

2012-04-20 15:41 本站整理 浏览(13)

后台定义:HttpServletRequest request,HttpServletResponse response,参数是必须有的

protected StringgetComUnit(HttpServletRequest request,HttpServletResponse response, ModelMapmodelMap){

StringBuffer sql =

newStringBuffer();

sql.append(" select Distinct \n");

…………………………………………………………………………….

try {IRowSet rs = com.kingdee.eas.util.app.DbUtil.executeQuery(this.getWafContext().getInstance().getContext(),sql.toString());

Map map = new HashMap();

Map keymap = new HashMap();

List list = new ArrayList();

String id = null;while(rs.next()){

//

同一个公司的

if(id!=null && !id.equals(rs.getString("ID"))){list.add(map);

map = new HashMap();

}

String type = rs.getString("NUMBER");

if(type!=null && !"".equals(type)){if(type.equals("z0001"))

map.put("name", rs.getString("VALUE"));

elseif(type.equals("z0002"))map.put("number", rs.getString("VALUE"));

elseif(type.equals("z0004"))map.put("date", rs.getString("VALUE"));

elseif(type.equals("z0005"))map.put("englishName", rs.getString("VALUE"));

id = rs.getString("ID");

}

}

JSONUtils.SUCCESS(list);

}

returnnull;}

传到前台的数据是JSONUtils.SUCCESS(list);

List里面是Map<”number”,”A001”>

前台解析代码:

abc:function(){

jQuery("#dataGrid1").jqGrid("clearGridData");

var arrIds =jQuery("#dataGrid1").jqGrid('getDataIDs');

var i = 1;

waf.doPost({

action:'getComUnit', //实现类的方法名

success:function(data){

jQuery.each(data,function(idx,item){

varrowdata = {

comNumber:item.number,

comName:item.name,

comModou:item.englishName,

comBtn:"<ahref = \"javascript:void(0)\" onclick = \"btn()\">查看</a>"

};

waf('#dataGrid1').jqGrid('addRowData',i, rowdata);//表添加行

i++;

}

);

}

});

}