easyui datagrid 绑定json对象属性的属性

今天用easyui 的datagrid绑定数据时,后台提供的数据是实体类类型的,其中有一个实体类A的属性b是另一个实体类B类型的,而前台需要显示b的属性c,这下就悲剧了,前台没法直接绑定了,后来脑筋一转,想到了datagrid的列属性formatter,formatter提供了row,这样的话我们在formatter里面指定一下不就可以了吗

于是~

function dgDevice_datagrid() {
$('#dgDevice').datagrid({
url: 'DeviceList.ashx?action=GetDevices',
toolbar: '#tb1',
width: 540,
singleSelect: true,
remoteSort: true,
sortName: 'SaleDate',
sortOrder: 'desc',
rownumbers: true,
columns: [[
{ title: '设备ID', field: 'DeviceID', width: 190, align: 'center' },
{ title: '出厂日期', field: 'ExFactoryDate', width: 110, align: 'center',
formatter: function (val) {
return formatDate(val, "yyyy-MM-dd");
}
},
{ title: '售卖日期', field: 'SaleDate', width: 110, align: 'center',
formatter: function (val) {
return formatDate(val, "yyyy-MM-dd");
}
},
{ title: '账户', field: 'AccountName', width: 80, align: 'center',
formatter: function (value, row, index) {
return row.Account.AccountName;
}
}
]],
onSelect: function (rowIndex, rowData) {
dgSensor_datagrid(rowData.DeviceID);
}
});
}

完美~

上一篇:Linux下安装搜狗输入法


下一篇:Nginx环境中如何将HTTP跳转至HTTPS设置