如何解决Kendo Grid Angular-具有反应形式控件的内联编辑-Addrow和Edit
我正在使用角型剑道网格,在其中使用反应式形式添加带有很少输入控件(文本区域,下拉列表)的内联行。我的情况是我必须在网格中添加一行,然后对其进行编辑。添加行后,有什么方法可以显式触发编辑处理程序。网格的Editrow不能按预期工作。
public addHandler({ sender }: AddEvent): void {
this.closeEditor(sender);
this.formGroup = new FormGroup({
'ActivityAgendaId': new FormControl(''),'Agenda': new FormControl('',[Validators.required,Validators.maxLength(100)]),// 'Category': new FormControl('',Validators.required),'Status': new FormControl("NTdisCUSED",'Mom': new FormControl("",[]),'Action': new FormControl(''),});
this.isNew = true;
if (this.isFutureDatedMeeting()) {
this.formGroup.controls['Status'].disable();
}
this.formGroup.controls['Mom'].disable();
sender.addRow(this.formGroup);
}
private onDocumentClick(e: any): void {
if (this.formGroup && this.formGroup.valid &&
!matches(e.target,'#agendaGrid tbody *,#agendaGrid .k-grid-toolbar .k-button')) {
this.saveRow();
}
}
private saveRow(): void {
if (this.formGroup && !this.formGroup.valid) {
return;
}
if (this.formGroup) {
const selectedAgenda = this.formGroup.getRawValue();
if (this.isNew) {
this.newRowIndex = this.newRowIndex + 1;
selectedAgenda.ActivityAgendaId = this.newRowIndex;
selectedAgenda.Action = ActivityContants.ACTIONINSERT;
this.selectedActivity.agenda.splice(0,selectedAgenda);
} else {
Object.assign(
this.selectedActivity.agenda.find(({ ActivityAgendaId }) => ActivityAgendaId === selectedAgenda.ActivityAgendaId),selectedAgenda
);
}
this.closeEditor(this.grid);
}
}
public editHandler({ sender,columnIndex,rowIndex,dataItem }: CellClickEvent): void {
// if (this.formGroup && !this.formGroup.valid) {
// return;
// }
// this.saveRow();
if (!this.isReadonly) {
this.formGroup = new FormGroup({
'ActivityAgendaId': new FormControl(dataItem.ActivityAgendaId),'Agenda': new FormControl(dataItem.Agenda,// 'Category': new FormControl(dataItem.Category,'Status': new FormControl(dataItem.Status,'Mom': new FormControl(dataItem.Mom,'Action': new FormControl(dataItem.Action),});
this.editedRowIndex = rowIndex;
if (this.isFutureDatedMeeting()) {
this.formGroup.controls['Status'].disable();
this.formGroup.controls['Mom'].disable();
}
sender.editRow(rowIndex,this.formGroup,{ columnIndex });
}
}
private closeEditor(grid: GridComponent,rowIndex: number = this.editedRowIndex): void {
this.isNew = false;
grid.closeRow(rowIndex);
this.editedRowIndex = undefined;
this.formGroup = undefined;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。