有两个实体:
public class WatchType implements Serializable{
private Long watchTypeId;
private String watchTypeName;
private String description;
......
}
public class Result {
}
resultMap
<resultMap id="allWatchType" class="cn.com.pattek.eneity.WatchType">
</resultMap>
<select id="getWatchTypeStore" resultMap="allWatchType" >
</select>
<resultMap id="result" class="cn.com.pattek.eneity.Result">
</resultMap>
<select id="getResultByCondition" resultMap="result">
</select>
action中得到result对象的list集合,将该list放入jaon数据中:
Pagination p = new Pagination(start, limit, totalCount);
p.setList(resultList);
这样在页面中得到的数据格式如下:[{resultId:'',name:'',"allWatchType":{"description":"","watchTypeId":2,"watchTypeName":"全天节目监看"}}]
前台页面获得数据的方式(以ext store为例):fileds中{‘resultId','name','allWatchType.watchTypeId',' allWatchType.watchTypeName'}即可获得watchType 的id、name
在column中的对应:{
dataIndex : 'allWatchType' ,
align : 'center',
//加此render的目的是
renderer :function(value, metadata, record){
if(value=="" || value == null){
return "";
}else{
return record.get(' allWatchType ').watchTypeId;
}
}
}