gpt4 book ai didi

angular - Ng2智能表,从一个对象中获取多列

转载 作者:行者123 更新时间:2023-12-01 23:45:05 27 4
gpt4 key购买 nike

我正在使用 ng2 智能列来显示包含用户对象的交易。我想在不同的列中显示 id 用户、姓名和电子邮件。我该怎么做?

settings = {
add: {
addButtonContent: '<i class="nb-plus"></i>',
createButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmCreate : true
},
edit: {
editButtonContent: '<i class="nb-edit"></i>',
saveButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmSave : true
},
delete: {
deleteButtonContent: '<i class="nb-trash"></i>',
confirmDelete: true,
},
columns: {
id: {
title: 'ID',
type: 'number',
},

user: {
title : 'name',
valuePrepareFunction: (data) => {
return data.email;
},
},

amount: {
title: 'Valeur',
type: 'number',

},
items: {
name: { title: 'Nom' },
},

state: {
title: 'Etat',
type: 'string',
},
delivery_date: {
title: 'Date de livraison',
type: 'string',
},
expedition_date: {
title: 'Date d\'expedition',
type: 'string',
},
},
};

在这个链接上查看 https://stackblitz.com/edit/example-ng2-smart-table-ytzrns?file=src/app/app.component.ts

最佳答案

这是解决方案

  
'user.firstName': {
title: 'Name',
valuePrepareFunction: (cell, row) => { return row.user.firstName }
},


'user.lastName': {
title: 'Last name',
valuePrepareFunction: (cell, row) => { return row.user.lastName }
},
'user.address': {
title: 'address',
valuePrepareFunction: (cell, row) => { return row.user.address }
},
'user.email': {
title: 'email',
valuePrepareF

关于angular - Ng2智能表,从一个对象中获取多列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64318710/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com