Hi,
I have a treegrid component configured in my angular app. If I set a column's edit type dynamically, and then try to add a row, the row vanishes when I press enter to save the row. Please help.
|
App.Component.html
<ejs-treegrid #treegrid [dataSource]='data' height='350' childMapping='subtasks' [treeColumnIndex]='1' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='taskID' headerText='Task ID' width='70' isPrimaryKey='true' textAlign='Right' [edit]='numericParams' [validationRules]='taskidrules'></e-column>
<e-column field='taskName' headerText='Task Name' width='200' [validationRules]='tasknamerules' [edit]='dpParams'></e-column>
>
</e-columns>
</ejs-treegrid>
App.Component.ts
export class AppComponent {
public data: Object[] = [];
public autoCompleteObj: any;
@ViewChild('treegrid')
public treegrid: TreeGridComponent;
ngOnInit(): void {
this.data = sampleData;
this.editSettings = {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: 'Row',
};
this.dpParams = {
create: () => {
let elem: HTMLInputElement = document.createElement('input');
elem.id = 'taskname';
return elem;
},
read: () => {
return this.autoCompleteObj.value;
},
destroy: () => {
this.autoCompleteObj.destroy();
},
write: (args: {
rowData: Object;
column: Column;
element: HTMLElement;
}) => {
if ((args.rowData as any).taskName == 'Plan timeline') {
this.autoCompleteObj = new AutoComplete({ //render AutoComplete
dataSource: <{ key: string; value: any }[]>(
this.treegrid.grid.dataSource
),
fields: { value: 'taskName' },
value: args.rowData[args.column.field],
});
this.autoCompleteObj.appendTo(args.element);
} else {
this.autoCompleteObj = new DropDownList({ //render dropdown
dataSource: <{ key: string; value: any }[]>(
this.treegrid.grid.dataSource
),
fields: { value: 'taskName' },
value: args.rowData[args.column.field],
});
this.autoCompleteObj.appendTo(args.element);
}
},
};
}
} |
Hello, thanks for responding. I solved this issue. I was not setting column.edit to the appropriate edit cell when setting edit type. Works now. Thanks.