66
77<template >
88 <div id =" app" >
9+ <button @click =" populate()" >populate tree</button >
910 <ul class =" g8-tree-view g8-tree__highlight_hover" >
1011 <g8-tree-view
1112 checker =" 1"
2526
2627<script lang="ts">
2728import {Component , Vue } from ' vue-property-decorator' ;
28- import {G8TreeView , G8TreeItem } from ' ./' ;
29+ import {G8TreeItem , G8TreeView } from ' ./' ;
2930
3031@Component ({
3132 components: {
@@ -35,37 +36,7 @@ import {G8TreeView, G8TreeItem} from './';
3536export default class App extends Vue {
3637 item: G8TreeItem = {
3738 key: ' root' ,
38- name: ' root name' ,
39- tags: [{key: ' root tag' , label: ' root label' }],
40- children: [
41- {
42- key: ' item-1' ,
43- name: ' item 1' ,
44- tags: [
45- {key: 1 , label: ' tag1.1' },
46- {key: 1 , label: ' tag1.2' , hint: ' 2nd tag in the 2nd branch' },
47- ],
48- },
49- {
50- key: ' item-2' ,
51- name: ' item 2' ,
52- tags: [{key: 2 , label: ' tag1.1' }],
53- children: [
54- {
55- key: ' item-2.1' ,
56- name: ' item 2.1' ,
57- tags: [
58- {key: ' 2.1.1' , label: ' tag2.1.1' },
59- {key: ' 2.1.2' , label: ' tag2.1.2' },
60- ],
61- },
62- {
63- key: ' item-2.2' ,
64- name: ' item 2.2' ,
65- },
66- ],
67- },
68- ],
39+ name: ' Click the button above to populate me.' ,
6940 };
7041
7142 itemClicked = ' ' ;
@@ -75,6 +46,34 @@ export default class App extends Vue {
7546 tagClicked = ' ' ;
7647
7748 tagDblClicked = ' ' ;
49+
50+ populate() {
51+ const total = 1000 ;
52+ this .item = {
53+ key: ' root' ,
54+ name: ' root name' ,
55+ tags: [{key: ' root tag' , label: ' root label' }],
56+ children: [],
57+ };
58+ for (let i = 1 ; i < total ; i ++ ) {
59+ const child: G8TreeItem = {
60+ key: ` key-${i } ` ,
61+ name: ` name ${i } ` ,
62+ tags: [{key: ` tag-${i } ` , label: ` tag ${i } ` }],
63+ children: [],
64+ };
65+ for (let j = 1 ; j < total ; j ++ ) {
66+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67+ child .children ! .push ({
68+ key: ` key-${i } ` ,
69+ name: ` name ${i } ` ,
70+ tags: [{key: ` tag-${i } ` , label: ` tag ${i } ` }],
71+ });
72+ }
73+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74+ this .item .children ! .push (child );
75+ }
76+ }
7877}
7978 </script >
8079
0 commit comments