[Vuejs]-TreeTable in Primevue does not show labels

1👍

TreeNode elements for the <TreeTable> component require just key and data properties, where data is an object containing key-values for each column.

Example involving columns for "Name", "Size" and "Type"

[
    {
        key: '0',
        data: {
            name: 'Applications',
            size: '100kb',
            type: 'Folder'
        },
        children: [
            {
                key: '0-0',
                data: {
                    name: 'Vue',
                    size: '25kb',
                    type: 'Folder'
                },
                children: [
                    {
                        key: '0-0-0',
                        data: {
                            name: 'vue.app',
                            size: '10kb',
                            type: 'Application'
                        }
                    },
                    {
                        key: '0-0-1',
                        data: {
                            name: 'native.app',
                            size: '10kb',
                            type: 'Application'
                        }
                    },
                    {
                        key: '0-0-2',
                        data: {
                            name: 'mobile.app',
                            size: '5kb',
                            type: 'Application'
                        }
                    }
                ]
            },
            {
                key: '0-1',
                data: {
                    name: 'editor.app',
                    size: '25kb',
                    type: 'Application'
                }
            },
            {
                key: '0-2',
                data: {
                    name: 'settings.app',
                    size: '50kb',
                    type: 'Application'
                }
            }
        ]
    }
]

The documentation is really bad at explaining this, and the included code snippets don’t show the correct format either, but clicking the links to view the examples in codesandbox or stackblitz will finally show the correct format being used.

codesandbox example

👤yoduh

Leave a comment