【发布时间】:2019-01-16 14:54:10
【问题描述】:
我正在使用 Angular 6.1.1 和 HandsonTables 5.0.0
我的热表正在正确显示并填充了数据。我已将一列设置为可编辑,但是当我通过在该列中输入更改值时,afterChange 事件根本没有触发,配置如下所示。
组件 HTML:
<hot-table [hotId]="hotInstance" [settings]="hotSettings"
[data]="dataset" (afterChange)="onAfterChange($event)"></hot-table>
组件 TS(ngOnInit 和 FetchData 调用正常,编辑 FieldA 时不会引发 onAfterChange):
export class PartsComponent implements OnInit {
dataset: any;
fetched = false;
error = false;
hotInstance: string = 'hot';
user : object = {};
hotSettings = { };
constructor(private route: ActivatedRoute,
private location: Location,
private repositoryService: RepositoryService,
private hotRegisterer: HotTableRegisterer,
private auth: AuthService) {
const $component = this;
this.hotSettings = {
colHeaders: ['System ID', 'Field A', 'Field B.'],
columns: [
{
data: 'Id',
type: 'numeric',
readOnly: true
},
{
data: 'FieldA',
type: 'text',
readOnly: false
},
{
data: 'FieldB',
type: 'text',
readOnly: true
}
],
allowInsertColumn: false,
allowRemoveColumn: false,
selectionMode: 'single',
//contextMenu: ['remove_row'],
rowHeaders: true,
filters: true,
dropdownMenu: ['filter_by_condition', 'filter_action_bar'],
height: 400,
outsideClickDeselects: false,
hiddenRows: {
indicators: false
}
};
}
ngOnInit() {
this.auth.getUser().subscribe(
usr => {
console.debug('parts.ngOnInit()');
console.debug(usr);
this.fetchData();
}, e => console.debug(e)
);
}
fetchData():void {
console.debug("fetchData()")
this.repositoryService.getParts()
.subscribe(
parts => this.dataset = parts,
err => this.error = true,
() => this.fetched = true
);
}
onAfterChange($event) {
console.debug('onAfterChange()'); \\ <--- not being called
console.debug($event);
}
}
【问题讨论】:
-
你有没有想过这个问题?同样的问题。
-
@oakfish56 看看我的回答,希望对你有帮助。
标签: angular handsontable