I have a table built by ng2-smart-table, data in the table has two states as Draft
and Ready
. When data.status = 'Draft'
, it's possible to show actions column for CRUD purpose, but then the state changes to data.status = 'Ready'
, I want to disabled the actions column. How to do this conditionally?
table setting:
tableSettings = {
add: {
addButtonContent: '<i class="fas fa-plus fa-fw"></i>',
createButtonContent: '<i class="fas fa-plus fa-fw"></i>',
cancelButtonContent: '<i class="fas fa-times fa-fw"></i>',
confirmCreate: true
},
edit: {
editButtonContent: '<i class="fas fa-pencil-alt fa-fw"></i>',
saveButtonContent: '<i class="fas fa-check fa-fw"></i>',
cancelButtonContent: '<i class="fas fa-times fa-fw"></i>',
confirmSave: true
},
delete: {
deleteButtonContent: '<i class="far fa-trash-alt fa-fw"></i>',
confirmDelete: true
},
columns: {
title: {
title: 'Title',
type: 'text',
filter: false,
},
description: {
title: 'description',
type: 'text',
filter: false,
}
}
};
ngOnInit() {
this.apiService.getData.subscribe((res: any) => {
this.data = res;
console.log(this.data.status);
});
}
Very Useful tips for hidding edit and delete icons (ngx-smart-table) Add this to your component css
I will customization by myself.
add your css file
My requirement is use edit authorized user.
maybe a bit late, but in your settings set "actions: false" and this, you can do dynamic with a variable
Follow my approach: First I created a custom action component:
Register at module and register at entryComponents!
Use your configuration on your ng2-smart-table
list.component.ts