我已经用ng2-smart-table设计了一个表,但是我仍然缺少一个重要的函数。
我希望能够隐藏和显示列。
您知道这是如何使用ng2-smart-table的吗?
我还没能在其他地方找到解决方案。
发布于 2018-02-08 21:39:41
设置={
// Meldung wenn keine Daten gefunden wurden oder tbody leer ist
noDataMessage: 'Es wurden keine Daten gefunden',
// Aktionen操作: false,
筛选器: false,
// Seitenzahl
pager: {
display: true,
perPage: 10,
},
// CRUD
add: {
addButtonContent: '<i class="fa fa-plus" title="hinzufügen"></i>',
createButtonContent: '<i class="fa fa-check" title="erstellen"></i>',
cancelButtonContent: '<i class="fa fa-close" title="abbrechen"></i>',
},
edit: {
editButtonContent: '<i class="fa fa-pencil" title="bearbeiten"></i>',
saveButtonContent: '<i class="fa fa-floppy-o" title="speichern"></i>',
cancelButtonContent: '<i class="fa fa-close" title="abbrechen"></i>',
confirmSave: true,
},
delete: {
deleteButtonContent: '<i class="fa fa-trash-o"></i>',
confirmDelete: true,
},发布于 2018-02-20 21:31:41
我已经用这种方式从Settings对象中删除了属性:
//My settings
settings = {
// Columns Specifications
columns: {
id: {
title: 'Id',
editable: 'false'
},
job: {
title: 'Job Name',
editable: 'false'
},
status: {
title: 'Status',
editable: 'false'
},
trigger: {
title: 'Trigger',
editable: 'false'
}
}
};
hideColumnForUser(){
if(!this.isAdmin){
delete this.settings.columns.job;
delete this.settings.columns.trigger;
}
}我在ngOnInit()中调用了hideColumnForUser()方法。
发布于 2018-04-12 23:29:41
我已经这样解决了:
我放了一个属性"show":true,设置如下
"columns": {
"id": {
"title": "id",
"show": false
},我添加了这段代码
if (this.settings.columns["id"].hasOwnProperty("show")) {
if (this.settings.columns["id"].show ==false) {
delete this.settings.columns["id"];
}
}我不知道是否有其他方法,但从我的角度来看,它是有效的。
https://stackoverflow.com/questions/48485816
复制相似问题