diff --git a/src/assets/menu/menu.json b/src/assets/menu/menu.json index eea2e8587..f1d7e1619 100644 --- a/src/assets/menu/menu.json +++ b/src/assets/menu/menu.json @@ -459,6 +459,10 @@ { "name": "Filter", "to": "/tree/filter" + }, + { + "name": "Scroll", + "to": "/tree/scroll" } ] }, diff --git a/src/components/tree/Tree.d.ts b/src/components/tree/Tree.d.ts index c4dfbc275..897c97a05 100755 --- a/src/components/tree/Tree.d.ts +++ b/src/components/tree/Tree.d.ts @@ -13,6 +13,7 @@ interface TreeProps { filterMode?: string; filterPlaceholder?: string; filterLocale?: string; + scrollHeight?: string; } declare class Tree { diff --git a/src/components/tree/Tree.vue b/src/components/tree/Tree.vue index 0cf4fc83e..06b0c55d4 100755 --- a/src/components/tree/Tree.vue +++ b/src/components/tree/Tree.vue @@ -10,11 +10,13 @@ @keydown="onFilterKeydown" v-model="filterValue" /> -
Scrolling is used to preserve space as content of the tree is dynamic and enabled by scrollHeight property.
+
+<Tree :value="nodes1" scrollHeight="200px"></Tree>
+
+
+
+ In cases where viewport should adjust itself according to the table parent's height instead of a fixed viewport height, set scrollHeight option as flex. In example below, + table is inside a Dialog where viewport size dynamically responds to the dialog size changes such as maximizing.
+ +
+<Button type="button" icon="pi pi-external-link" label="View" @click="dialogVisible = true"></Button>
+
+<Dialog header="Flex Scroll" v-model:visible="dialogVisible" :style="{width: '50vw'}" maximizable
+ :contentStyle="{height: '300px'}" class="p-fluid">
+ <Tree :value="nodes2" scrollHeight="flex"></Tree>
+ <template #footer>
+ <Button type="button" icon="pi pi-check" @click="dialogVisible = false" class="p-button-text"></Button>
+ </template>
+</Dialog>
+
Scrolling is used to preserve space in cases when rendering large data.
+Scrollable viewport is fixed.
+Flex scroll feature makes the scrollable viewport section dynamic so that it can grow or shrink relative to the parent size of the tree. Click the button below + to display maximizable Dialog where data viewport adjusts itself according to the size changes.
+ + + +