在 JeeSite 列表中,在业务中有需要查看子表数据。具体方法为:
列表页面中,在原 dataGrid 上的 columnModel 下面增加:
// 子表格支持演示
subGrid: true,
subGridRowExpanded: function (subTableId, rowId) {
$('#'+subTableId).html('<h5><i class="icon-docs"></i> 运费支付明细</h5>'+'<table id="'+subTableId+'_detail"></table>');
$('#'+subTableId+'_detail').dataGrid({
url: '${ctx}/product/flowPaymentFreight/flowPaymentFreightRecordListData',
postData: {'paymentFreightCode': rowId},
autoGridHeight: function(){return 'auto'}, // 设置自动高度
autoGridWidth: function(){return $("#"+subTableId).width()}, // 设置自动高度
// 设置数据表格列
columnModel: [
{header:'${text("收货单位")}', name:'customer', width:150, align:"center",
formatter: function(val, obj, row, act){
return js.val(row, 'customer.customerName');
}},
{header:'${text("发货时间")}', name:'shippingDate', width:150, align:"center"},
{header:'${text("单重")}', name:'weight', width:150, align:"center"},
{header:'${text("包装类型")}', name:'packCode', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('package_type')}, val, '${text("未知")}', true);
}},
{header:'${text("包装件数")}', name:'packNum', width:150, align:"center"},
{header:'${text("收货人")}', name:'addressee', width:150, align:"center"},
{header:'${text("收货人电话")}', name:'addresseeMobile', width:150, align:"center"},
{header:'${text("距离")}', name:'distance', width:150, align:"center"},
{header:'${text("吨/公里")}', name:'tonneKm', width:150, align:"center"},
{header:'${text("总运费")}', name:'totalAmount', width:150, align:"center", formatter: function(val, obj, row, act){
return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值,金额情况下设置0.00);
}},
],
emptyDataHint: true, // 表格内没有数据的时候提示 “无数据显示” v4.1.7
// 加载成功后执行事件
ajaxSuccess: function(data){
$(window).resize();
}
});
},控制器中:
/**
* 查询子表数据
*/
@RequiresPermissions("product:flowPaymentFreight:view")
@RequestMapping(value = "flowPaymentFreightRecordListData")
@ResponseBody
public Page<FlowPaymentFreightRecord> subListData(FlowPaymentFreightRecord flowPaymentFreightRecord, HttpServletRequest request, HttpServletResponse response) {
flowPaymentFreightRecord.setPage(new Page<>(request, response));
Page<FlowPaymentFreightRecord> page = flowPaymentFreightService.findSubPage(flowPaymentFreightRecord);
return page;
}