題主使用 EasyUI DataGrid,需在 `columns` 定義中為 `NAME` 列添加超鏈接。
columns: [[
{ title: '編碼', field: 'ID', width: 100, align: 'left' },
{
title: '名稱',
field: 'NAME',
width: 150,
align: 'left',
formatter: function(value, row, index) {
// row 包含整行數據,可用 row.ID、row.categoryID 等
return '' + value + '';
}
},
{ title: '發布時間', field: 'newsCreateTime', width: 100, align: 'center' }
]]
formatter: function(value, row, index) {
return '' + value + '';
},
onLoadSuccess: function(data) {
$('.detail-link').click(function() {
var id = $(this).data('id');
// 單頁應用路由跳轉或彈窗
openDetail(id);
});
}
避免整頁跳轉,提升體驗。