具體需求:
點擊列表裏面的用戶名.顯示用戶詳細信息
js:
{
field: 'customer.nickname',
width: "120px",
title: __('Customer.nickname'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text:function (row) {
return row.customer.nickname
},
title:function (row) {
return row.customer.nickname
},
classname: 'btn-dialog',
url: function (row) {
return '/hVvsKEQZnx.php/customer/edit/ids/'+row.customer.id
}
}
],
formatter: Table.api.formatter.buttons,
operate: "LIKE"
},
注意點:
控制器裏面一定要顯示用戶的ID,否則鏈接會出錯
$row->visible(['customer']);
$row->getRelation('customer')->visible(['nickname', 'id']);
最終效果: