Hi,
I am struggling to understand how to build the items model to work with the Tree Grid. In the documentation a dataProvider is used, but I have the full data model in the client using Lit/TypeScript. More specifically I don’t understand how the itemHasChildrenPath should be used.
VS Copilot suggested this:
import { html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import '@vaadin/grid/vaadin-grid.js';
import '@vaadin/grid/vaadin-grid-tree-column.js';
@customElement('my-tree-grid')
export class MyTreeGrid extends LitElement {
@property({ type: Array })
items = [
{
name: 'Parent 1',
children: [{ name: 'Child 1.1' }, { name: 'Child 1.2' }],
},
{
name: 'Parent 2',
children: [{ name: 'Child 2.1' }, { name: 'Child 2.2' }],
},
];
render() {
return html`
<vaadin-grid .items=${this.items} item-has-children-path="children">
<vaadin-grid-tree-column header="Name" path="name"></vaadin-grid-tree-column>
</vaadin-grid>
`;
}
}
… but it results in this: