EasyUI DataGrid formatter 格式化增加链接
function fLoadTable() {
$('#tt').datagrid({
title: '',
url: location.href,
pagination: true,
pageSize: 20,
pagePosition: 'top',
striped: true,
singleSelect: true,
rownumbers: true,
columns: [[
{
field: 'ID', title: 'ID', align: 'center', formatter: function (value, row, index) {
return row.Room_id;
}
},
{ field: 'FullBdName', title: '建筑', align: 'center' },
{ field: 'RoomName', title: '房间', align: 'center' },
{ field: 'ModuleAddr', title: '电表', hidden: true, align: 'center' },
{ field: 'ModuleCurrValue', title: '当前电表读数', align: 'center' },
{ field: 'ModuleRdValue', title: '当前电表剩余量', hidden: true, align: 'center' },
{ field: 'MthPayValue', title: '本月购电量', align: 'center' },
{ field: 'MthBaseValue', title: '本月赠电量', align: 'center' },
{ field: 'MthAcpValue', title: '上月结电量', align: 'center' },
{ field: 'MthUseValue', title: '本月用电量', align: 'center' },
{ field: 'DayUseValue', title: '本日用电量', align: 'center' },
{ field: 'syValue', title: '当前剩余电量', align: 'center' },
{ field: 'isSSR_S', title: '继电器状态', align: 'center' },
{ field: 'Update_dt', title: '最后通信时间', align: 'center' },
{ field: 'Room_id', title: '查看详细', align: 'center', formatter: fInfo }//主要是看这里
]]
});
};
function fInfo(rowIndex, rowData) {
return '<a href="javascript:fOpenRoomDetail(\'' + rowIndex + '\',\'' + rowData.Room_id + '\',\'' + rowData.FullBdName + '\',\'' + rowData.RoomName + '\')">详情</a>';
}
function fOpenRoomDetail(rowIndex, Room_id, FullBdName, RoomName) {
parent.fOpenRoomDetail(rowIndex, Room_id, FullBdName, RoomName);
//$('#dlg').dialog({
// title: FullBdName + '->' + RoomName + '→详情',
// width: 935,
// height: 650,
// closed: false,
// cache: false,
// collapsible: true,
// maximizable: true,
// resizable: true,
// shadow: true,
// left: 50,
// top: 10,
// //href: '/ShowData.aspx?RoomID=' + rowIndex,
// modal: true,
// content: '<iframe frameborder="0" src="/ShowData.aspx?RoomID=' + Room_id + '" style="height: 98%; width: 100%;" ></iframe>'
//});
}