1.在colModel中写
{label: '设备类型', name: 'deviceType', index: 'device_type', width: 80,editable: true,
formatter: function (value) {
return vm.fmtDeviceType(value);
}
},
2.方法:查询数据库中的值
fmtDeviceType:function(value){
//这个方法使用ajax查询了数据库
vm.getType();
var devicelist = vm.deviceTypeList;
console.log(vm.deviceTypeList)
var a ="未知设备";
for (x in devicelist) {
var code = devicelist[x].code;
if (value == code) {
var val = devicelist[x].value;
a=val;
}
}
return '<span class="label label-info">'+a+'</span>';
},