Hoà*_*yễn 5 ng2-smart-table angular
我有一个由 ng2-smart-table 构建的表,表中的数据有两种状态Draft和Ready。当 时data.status = 'Draft',可以出于 CRUD 目的显示操作列,但随后状态更改为data.status = 'Ready',我想禁用操作列。如何有条件地做到这一点?
桌面设置:
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);
});
}
Run Code Online (Sandbox Code Playgroud)
我会自己定制。
settings = {
columns: {
name: {
title: 'Name',
filter: true
}
},
mode: 'external',
actions: {
delete: false,
add: false,
position: 'right'
},
rowClassFunction: (row) => {
var curUserId = localStorage.getItem('user_id');
if(row.data.createdBy == parseInt(curUserId)){
return '';
} else {
return 'hide-action';
}
},
edit: {
editButtonContent: '<i class="ti-pencil text-info m-r-10"></i>'
}
};
source = new LocalDataSource([{name:'Jai', createdBy:12}, {name:'Jack', createdBy:63}])
Run Code Online (Sandbox Code Playgroud)
添加你的css文件
.hide-action td.ng2-smart-actions a {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
我的要求是使用编辑授权用户。
| 归档时间: |
|
| 查看次数: |
9883 次 |
| 最近记录: |