Editing
All five editing modes of the data grid work on trees — the demo below uses form mode with a two-column layout. New rows can be inserted under a chosen parent and prefilled via initNewRow.
editing.mode formItems addRow(parentKey) initNewRow
form mode prefill insert under parent
new rows arrive pre-titled "Engineer"
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { OgeTreeList } from '@oge-ui/tree-list';
@Component({
selector: 'demo-root',
imports: [OgeTreeList],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<oge-tree-list
[data]="org"
keyExpr="id"
parentIdExpr="parentId"
[editing]="{
mode: 'form',
allowUpdating: true,
allowAdding: true,
allowDeleting: true,
formColCount: 2,
formItems: ['name', 'title', { field: 'office', colSpan: 2 }]
}"
(initNewRow)="$event.values['title'] = 'Engineer'"
/>
<!-- treeList.addRow(parentKey) inserts under a chosen node -->
`,
})
export class Demo {
readonly org = [
{ id: 1, parentId: null, name: 'Aylin Koç', title: 'CEO', office: 'İstanbul', headcount: 4 },
{ id: 2, parentId: 1, name: 'Baran Ateş', title: 'VP Engineering', office: 'İstanbul', headcount: 2 },
{ id: 3, parentId: 2, name: 'Ceren Aksu', title: 'Team Lead', office: 'İzmir', headcount: 1 },
{ id: 4, parentId: 3, name: 'Deniz Ünal', title: 'Engineer', office: 'İzmir', headcount: 0 },
{ id: 5, parentId: 1, name: 'Elif Barış', title: 'VP Sales', office: 'Ankara', headcount: 0 },
];
}Notes
cell,row,batch,formandpopupmodes all ship; validation and*ogeEditTemplatecustom editors come from the shared column definitions.formItemsselects, orders, relabels and spans the form fields;formColCountfixes the layout columns.addRow(parentKey)pre-stages the parent reference, so the saved row lands under that node;initNewRowprefills any other field.- Saves flow through the cancelable
savingChangesevent into the DataSource; on lazy trees the affected levels re-fetch so the UI always shows persisted values.