英文:
How can I start row edit mode on a new form control in a primeng table?
问题
我有一个从表单数组中获取数据的PrimeNG表格。
我想在该表单数组的新表单控件上以编程方式启动行编辑模式。
我一直在尝试使用这个函数,但我不知道如何正确使用它:
table.initRowEdit();
public addNewElement(): void {
const newFormGroup = new FormGroup({
code: new FormControl(null),
type: new FormControl(null),
});
this.formArray.insert(0, newFormGroup);
this.table.initRowEdit(this.formArray.controls[0]);
}
如果我在模板中点击带有注释的按钮:pInitEditableRow,它会按预期工作。但是我想添加一行新数据并在不必点击任何按钮的情况下开始编辑。
英文:
I have a primeng table that takes data from a form array.
I want to start row edit mode on a new form control of that form array programmatically.
I've been trying using this function but I do not know how to use it properly:
table.initRowEdit();
public addNewElement(): void {
const newFormGroup = new FormGroup({
code: new FormControl(null),
type: new FormControl(null),
});
this.formArray.insert(0, newFormGroup);
this.table.initRowEdit(this.formArray.controls[0]);
}
If I click in the template button annotated with: pInitEditableRow it works as expected. But I want to add a new row and start editing it without having to click in any button.
答案1
得分: 1
好的,
我找到了解决方案...
public addNewElement(): void {
const newFormGroup = new FormGroup({
code: new FormControl(null),
type: new FormControl(null),
});
this.formArray.insert(0, newFormGroup);
this.table.initRowEdit(this.formArray.controls[0].value);
}
英文:
Ok,
I've found the solution...
public addNewElement(): void {
const newFormGroup = new FormGroup({
code: new FormControl(null),
type: new FormControl(null),
});
this.formArray.insert(0, newFormGroup);
this.table.initRowEdit(this.formArray.controls[0].value);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论