gpt4 book ai didi

angular - ng2-smart-table 创建按钮无法正常工作

转载 作者:行者123 更新时间:2023-12-02 10:17:04 27 4
gpt4 key购买 nike

我正在从 firebase 获取数据并用 ng2-smart-table 显示它.

但是,添加数据后添加对话框并未关闭。它仍然以添加的值打开。

这是我的代码:

settings = {
pager:{perPage:50},
add: {
addButtonContent: '<i class="ion-ios-plus-outline"></i>',
createButtonContent: '<i class="ion-checkmark"></i>',
cancelButtonContent: '<i class="ion-close"></i>',
confirmCreate: true,
},

要创建的函数:

onCreateConfirm(event): any {
//this service is updating the new data to firebase.
this.service.createData(event.newData);
//after that the newdata still on edit mode and not closing it...
}

最佳答案

Add this in your template html

     <ng2-smart-table [settings]="settings" [source]="source" 
(createConfirm)="onCreateConfirm($event)"
(deleteConfirm)="onDeleteConfirm($event)"
(editConfirm)="onSaveConfirm($event)">
</ng2-smart-table>

Component

    settings = {delete: {
confirmDelete: true
},
add: {
confirmCreate: true
},
edit: {
confirmSave: true
},
.......
}


source: LocalDataSource;

constructor() {
this.source = new LocalDataSource(this.data);
}

onDeleteConfirm(event):void {
if (window.confirm('Are you sure you want to delete?')) {
event.confirm.resolve();
} else {
event.confirm.reject();
}
}

onSaveConfirm(event):void {
if (window.confirm('Are you sure you want to save?')) {
event.newData['name'] += ' + added in code';
event.confirm.resolve(event.newData);
} else {
event.confirm.reject();
}
}

onCreateConfirm(event):void {
event.confirm.resolve(event.newData);
}

关于angular - ng2-smart-table 创建按钮无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40430893/

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