diff --git a/src/views/tree/TreeDoc.vue b/src/views/tree/TreeDoc.vue
index 97b1811c7..745c82247 100644
--- a/src/views/tree/TreeDoc.vue
+++ b/src/views/tree/TreeDoc.vue
@@ -112,36 +112,73 @@ import Tree from 'primevue/tree';
-
+
View on GitHub
<template>
<div>
- <div class="content-section introduction">
- <div class="feature-intro">
- <h1>TriStateCheckbox</h1>
- <p>TriStateCheckbox is used to select either "true", "false" or "null" as the value.</p>
- </div>
- </div>
+ <div class="content-section introduction">
+ <div class="feature-intro">
+ <h1>Tree</h1>
+ <p>Tree is used to display hierarchical data.</p>
+ </div>
+ </div>
- <div class="content-section implementation">
- <TriStateCheckbox v-model="value" />
- <p>Value: <span style="font-weight: bold">{{value == null ? 'null' : value}}</span></p>
- </div>
- </div>
+ <div class="content-section implementation">
+ <h3>Basic</h3>
+ <Tree :value="nodes"></Tree>
+
+ <h3>Programmatic Control</h3>
+ <div style="margin-bottom: 1em">
+ <Button type="button" icon="pi pi-plus" label="Expand All" @click="expandAll" />
+ <Button type="button" icon="pi pi-minus" label="Collapse All" @click="collapseAll" />
+ </div>
+ <Tree :value="nodes" :expandedKeys="expandedKeys"></Tree>
+ </div>
+ </div>
</template>
+import NodeService from '../../service/NodeService';
+
export default {
- data() {
- return {
- value: null
- }
- }
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.nodes) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {...this.expandedKeys};
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ this.expandedKeys[node.key] = true;
+ if (node.children && node.children.length) {
+ for (let child of node.children) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
}
diff --git a/src/views/tree/TreeFilterDemo.vue b/src/views/tree/TreeFilterDemo.vue
index f9915db39..44307dd7e 100644
--- a/src/views/tree/TreeFilterDemo.vue
+++ b/src/views/tree/TreeFilterDemo.vue
@@ -17,9 +17,64 @@
-
+
+
+
+
+
+<h3>Lenient Filter</h3>
+<Tree :value="nodes" :filter="true" filterMode="lenient"></Tree>
+
+<h3>Strict Filter</h3>
+<Tree :value="nodes" :filter="true" filterMode="strict"></Tree>
+
+
+
+
+import NodeService from '../../service/NodeService';
+
+export default {
+ data() {
+ return {
+ nodes: null,
+ expandedKeys: {}
+ }
+ },
+ nodeService: null,
+ created() {
+ this.nodeService = new NodeService();
+ },
+ mounted() {
+ this.nodeService.getTreeNodes().then(data => this.nodes = data);
+ },
+ methods: {
+ expandAll() {
+ for (let node of this.nodes) {
+ this.expandNode(node);
+ }
+
+ this.expandedKeys = {...this.expandedKeys};
+ },
+ collapseAll() {
+ this.expandedKeys = {};
+ },
+ expandNode(node) {
+ this.expandedKeys[node.key] = true;
+ if (node.children << node.children.length) {
+ for (let child of node.children) {
+ this.expandNode(child);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+