使用自定义标签获取子数组的数据
假如我想取到organDevice数组下的device对象数组中的devName 填充到设备名称中:
data :
**organDevices**:[
{devId:"000008",
**device** :{
deptId:"放射科",-
devId:"000008",
devModel: "方舱CT",
**devName** :"方舱CT"
},
id:1
organEnCode :"CS",
organEnName: "CS",
organId: "000222",
organId :"000222",
organName: "颈椎间盘",
organSort: "1"}
]
那么可以使用自定义标签:
html:
<script type="text/html" id="device">
{{#console.log(d)}}
<span style="font-weight: bold;font-size: 18px;">
{{ d.device.devName }}
</span>
<span style="background: #c9c9c9;border-radius: 3px;"></span>
</script>
js:
var organDeviceTable = table.render({
elem: '#dictOrganDevice',
height: $(window).height() - 230,
width: ($(window).width() / 5) * 3 - 100,
cols: [
[{
type: 'checkbox',
fixed: 'left'
},
{
**field: 'devName',**
**title: '设备名称',**
**fixed: 'left',**
**templet: '#device'**
}, {
field: 'organEnName',
width: 130,
title: '部位名称'
}, {
field: 'organEnCode',
width: 100,
title: '部位代码'
}, {
title: '操作',
width: 120,
align: 'center',
toolbar: '#dictOrganDevice-barDemo',
fixed: 'right'
}
]
],
limit: 100000,