我正在尝试使用ng2-smart-table这个问题我不知道如何将加号按钮(addButtonContent)与一些创建函数数据绑定。现在这只是为我打开anther raw来插入数据。 还有怎么做编辑按钮。 我的代码是:
settings = {
add: {
addButtonContent: '<i class="ion-ios-plus-outline"></i>', //how to call some function to this one
createButtonContent: '<i class="ion-checkmark"></i>',
cancelButtonContent: '<i class="ion-close"></i>',
},
edit: {
editButtonContent: '<i class="ion-edit"></i>',
saveButtonContent: '<i class="ion-checkmark"></i>',
cancelButtonContent: '<i class="ion-close"></i>',
},
delete: {
deleteButtonContent: '<i class="ion-trash-a"></i>',
confirmDelete: true
},
和我的模板:
<ba-card title="Basic Example" baCardClass="with-scroll">
<div class="form-group">
<input #search type="search" class="form-control form-control-lg" placeholder="Search..." (keyup)="onSearch(search.value)">
</div>
<ng2-smart-table [settings]="settings" [source]="source" (deleteConfirm)="onDeleteConfirm($event)"></ng2-smart-table>
</ba-card>
答案 0 :(得分:9)
添加此
<ng2-smart-table class='form-control' [settings]="settings" [source]="source" (deleteConfirm)="onDeleteConfirm($event)" (editConfirm)="onSaveConfirm($event)"
(createConfirm)="onCreateConfirm($event)" ></ng2-smart-table>
然后在您的组件中调用新操作
onCreateConfirm(event):void {
}
onSaveConfirm(event):void {
}
onDeleteConfirm(event): void {
}
答案 1 :(得分:1)
我想评论Yousef Al Kahky的回答,但我是新来的,所以我必须再次回答:
您还必须添加confirmCreate: true
,否则将不会调用该方法。
add: {
addButtonContent: '<i class="nb-plus"></i>',
createButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmCreate: true,
},