Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node structure does not update when the data is updated via code #83

Open
tauseef-r-kazi opened this issue Dec 9, 2021 · 1 comment

Comments

@tauseef-r-kazi
Copy link

I am using v-model="pointer" to track the currently selected node. however, if I add a child node using the below code it does not reflect under this.pointer.children array. How can the under lying graph object be updated from the parent component?

addCondition(data) {
          const newData = {
                name: "NewNode",
                id: this.indexCounter++,
                type: "newType",
                children: []
          }
          data.children.push(newData);
      }

component definition:
<tree ref="tree" class="tree-class" :data="graph" v-model="pointer" node-text="name" layoutType="horizontal" :identifier="getId" @clickedText="onNodeTextClick" :zoomable="true" :marginX="0" :marginY="0">

@fardinvahdat
Copy link

yes youre right. use :key for update your DOM whenever your state updated. your code should by s.t like this: <tree :key="counter" ref="tree" class="tree-class" :data="graph" v-model="pointer" node-text="name" layoutType="horizontal" :identifier="getId" @clickedText="onNodeTextClick" :zoomable="true" :marginX="0" :marginY="0"/>`

addCondition(data) {
          const newData = {
                name: "NewNode",
                id: this.indexCounter++,
                type: "newType",
                children: []
          }
          data.children.push(newData);
this.counter++
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants