gpt4 book ai didi

angular - ng2智能表如何根据列值隐藏删除图标

转载 作者:太空狗 更新时间:2023-10-29 19:33:43 30 4
gpt4 key购买 nike

我已经集成了ng2智能表。

在操作列中,我显示了编辑和删除链接。

我想根据列值隐藏删除和编辑链接。如果状态为事件,则需要隐藏编辑和删除链接。

下面是我的设置

    settings = {
selectMode: 'multi',
mode: 'external',
hideSubHeader:true,
editable:false,
pager : {
display : true,
perPage:20
},
actions: { add: false, edit: true, delete:true, position:'right'},
edit: {
editButtonContent: '<i class="fa fa-pencil"></i>'
//mode: 'external'
},
delete: {
deleteButtonContent: '<i class="fa fa-trash" aria-hidden="true"></i>',
confirmDelete: true
},
columns: {
id: {
title: 'ID'
},
title: {
title: 'Title'
},
status: {
title: 'Status',
type: "html",
valuePrepareFunction: (value) => {
if(value == 'To be approved') {
return '<span class="unapproved">'+value+'</span>'
} else {
//actions.edit = false;
return '<span class="approved">'+value+'</span>'
}

}

}
}
};

这是我用过的代码

 <ng2-smart-table id="ng2_smart" [settings]="settings" [source]="data" (edit)="onEdit($event)" (delete)="onDelete($event, content)" (custom)="onCustom($event)" (userRowSelect)="selectedData($event)"></ng2-smart-table>

最佳答案

使用全局 bool 变量将其初始化为按状态列显示/隐藏。并在 Action 对象中使用它。试试下面的代码

 var isEditOrDelete=true;


settings = {
selectMode: 'multi',
mode: 'external',
hideSubHeader:true,
editable:false,
pager : {
display : true,
perPage:20
},
actions: { add: false, edit: isEditOrDelete , delete:
isEditOrDelete, position:'right'},
edit: {
editButtonContent: '<i class="fa fa- pencil"></i>'
//mode: 'external'
},
delete: {
deleteButtonContent: '<i class="fa fa-trash" aria-
hidden="true"></i>',
confirmDelete: true
},
columns: {
id: {
title: 'ID'
},
title: {
title: 'Title'
},
ststus:{
title: 'Status',
type: "html",
valuePrepareFunction: (value) => {
if(value == 'To be approved') {
isEditOrDelete = false;
return '<span class="unapproved">'+value+'</span>'
} else {
isEditOrDelete = true;
return '<span class="approved">'+value+'</span>'
}
}
}
}
};

关于angular - ng2智能表如何根据列值隐藏删除图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47966752/

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