UEP-主从表
Master Model:主表数据
Detail Model:从表数据
//页面中展示多个DataWrap时,用这个方法说明扩展的DataWrap对应的属性名称
@Override public List<String> getExtendDataWrapName() { List<String> list = new ArrayList<String>(); list.add("detailWrap"); list.add("invoiceWrap"); return list; }
//action:设计几张表定义几个AjaxDataWrap get、set方法
private AjaxDataWrap<UepCustomer> dataWrap = new AjaxDataWrap<UepCustomer>(); private AjaxDataWrap<UepContract> detailWrap = new AjaxDataWrap<UepContract>(); private AjaxDataWrap<UepInvoice> invoiceWrap = new AjaxDataWrap<UepInvoice>();
/** *主表查询操作 */ @Override public void retrieve() { QueryParamList params = getQueryParam("dataWrap"); dataWrap.setDataList(uepCustomerUepContractService.masterRetrieve(params, dataWrap.getPageInfo())); responseData.setAjaxDataWrap("dataWrap", dataWrap); } /** *从表查询操作 */ public void detailRetrieve() { QueryParamList params = getQueryParam("detailWrap"); params.addParam("customerId",new BigDecimal (customerId)); detailWrap.setDataList(uepCustomerUepContractService.detailRetrieve(params, detailWrap.getPageInfo())); responseData.setAjaxDataWrap("detailWrap", detailWrap); QueryParamList params1 = new QueryParamList(); params1.addParam("customerId",new BigDecimal(customerId)); invoiceWrap.getPageInfo().setRowOfPage(5); List<UepInvoice> dataList = uepCustomerUepContractService.invoiceRetrieve(params1, invoiceWrap.getPageInfo()); invoiceWrap.setDataList(dataList); responseData.setAjaxDataWrap("invoiceWrap",invoiceWrap); }
/** *初始化 */ @Override protected void initTreat() { super.retrieveAfterInit = true ; this.dataWrap.getPageInfo().setRowOfPage(15); this.invoiceWrap.getPageInfo().setRowOfPage(15); this.detailWrap.getPageInfo().setRowOfPage(15); }
function showDetail(cell){ var baseData = detail.collectData(true); //获取从表的信息 var dataArr = []; dataArr.push(baseData); var customerId = cell["id"]; //通过行对象获取主表ID //var record = master.getRecord(cell.rowIndex); //var customerId = record.get("id"); $.request({ action:"detailRetrieve", pageparam:"all", data:dataArr, params:{ customerId:customerId }, success:oncomplete }); } function oncomplete(){ detail.setData(response.getAjaxDataWrap("detailWrap"));
var invoiceWrap = response.getAjaxDataWrap("invoiceWrap");
invoiceGrid.setData(invoiceWrap);
}
谢谢大家的阅读,阅读后记得关注一下呦!