我希望能够在用户点击时将行切换到编辑模式
我曾尝试在my.component.html上使用 userRowSelect 事件:
<ng2-smart-table
class="class-content"
[settings]="settings"
[source]="source"
(deleteConfirm)="onDeleteConfirm($event)"
(editConfirm)="onSaveConfirm($event)"
(createConfirm)="onCreateConfirm($event)"
(rowSelect)="onRowSelect($event)"
(userRowSelect)="onUserRowSelect($event)"
>
</ng2-smart-table>
然后在my.component.ts中:
onUserRowSelect(e) {
console.log('onUserRowSelect', e);
}
没有成功
答案 0 :(得分:1)
我有类似的问题,最后我找到了解决方案:
在文档https://akveo.github.io/ng2-smart-table/#/documentation中,您有两个事件: rowSelect 或 userRowSelect
我们首先为我们的表设置一个名称,然后捕获 userRowSelect 操作:
<ng2-smart-table #table [settings]="settings" [source]="source" (userRowSelect)="switchToEdit($event)">
</ng2-smart-table>
在我们的组件中:
import {ViewChild} from '@angular/core';
...
@ViewChild('table') table: Ng2SmartTableComponent;
...
switchToEdit(event) {
this.table.grid.getSelectedRows().forEach((row) => {
this.table.grid.edit(row);
});
}