Comments (14)
just add it to the model, as in the docs
http://wix.github.io/angular-tree-control/#changing
from angular-tree-control.
How do i remove node?
from angular-tree-control.
exactly the same - update your model.
from angular-tree-control.
Is there an approach you had in mind for removing a node? The only way I can think of removing a node (from the actual node itself, i.e. a delete button on the node itself) out of the box is emit an event with the node to the containing controller and then walk the tree data and remove it from there. It seems less than ideal, is there another mechanism that would allow that kind of thing?
from angular-tree-control.
what would you imagine the tree doing?
On Wed, Jun 24, 2015 at 11:50 PM, Jake Buob [email protected]
wrote:
Is there an approach you had in mind for removing a node? The only way I
can think of removing a node (from the actual node itself, i.e. a delete
button on the node itself) out of the box is emit an event with the node to
the containing controller and then walk the tree data and remove it from
there. It seems less than ideal, is there another mechanism that would
allow that kind of thing?—
Reply to this email directly or view it on GitHub
#42 (comment)
.
from angular-tree-control.
I didn't know if there was something in place for a node to have knowledge of its parent so it could send the parent with the event and the directive could remove the node from the parent's children, or if there was an event already that a node could fire to its parent to remove itself. If either of those options sound interesting, I could investigate and submit a PR.
from angular-tree-control.
Any insight into this @yoavaa? I'm interested in doing the same thing that @buob is describing. I have a button next to each node which intends to remove said node from the tree, but to actually repaint the tree requires somehow walking the treeModel
to find this node and removing it. Unless of course we're exposed the path to the current node somehow. It seems like there could / should be an easier way to do this.
from angular-tree-control.
in another issue we have a discussion on getting, for a node, the path of parents to the root (or rather, the path to a node). While this is possible, it is not trivial and I am not sure about the API. It has to be a function that we can expose similar to the other tree label template variables (e.g. http://wix.github.io/angular-tree-control/#labels-template and http://wix.github.io/angular-tree-control/#events).
Do you think adding a $parents
which is a function returning an array of nodes will help?
from angular-tree-control.
@yoavaa That should definitely help. I too have a usecase that requires deleting nodes!
from angular-tree-control.
@buob @sethkrasnianski Did you guys manage to find a workaround for this?
from angular-tree-control.
@paambaati what is the usecase?
If it is that when a node is clicked you want to remove it, you can use the $parentNode parameter you get in events. With it you can get the parent node of the clicked node and remove it from the parent.
from angular-tree-control.
I think we were using a version before $parentNode
was available, so we ended up just storing parentNode
on each node ourselves before sending it to tree control and removing it that way.
from angular-tree-control.
I am updating my treeModel by splicing children OUT of the structure. Although the tree model updates as expected, the tree's transcludeScope goes out of synch with the new data structure.
The result is that the tree's label continues to display the removed node's data even while the scope's node property is properly updated.
Am I missing something necessary in order to successfully remove nodes?
from angular-tree-control.
Just an update to my prior question:
I discovered transcludeScopes for removed nodes remain synchronized with treeModel updates whenever NOT using the custom template option.
from angular-tree-control.
Related Issues (20)
- Inline editing of nodes HOT 2
- Is it possible to highlight the tree search result without hiding? HOT 1
- Error if HTML elsewhere on the page uses any CSS classes that angular-tree-control does.
- Which version of angular should I use when I using angular tree control?
- 0.2.30 Crashes Hard HOT 12
- 0.2.30 breaks after minification HOT 1
- binding node property in custom node template
- op HOT 1
- Add documentation for isSelectable(node) HOT 1
- Angular Tree control multiselection manual nodes selected not working
- example code is not correctly (Clicking Labels Expand & Collapse)
- [$injector:strictdi] function($parse) is not using explicit annotation and cannot be invoked in strict mode HOT 1
- Can you upgrade latest version 0.2.30 for bower?
- How to prevent from branch node selection, I just want to select files HOT 1
- npm install 0.2.30
- Auto select for children when we select parent node
- Existe alguma versão do projeto para angular 8 ?
- How to add aria-label to leaf?
- Disable nodes functionality
- Bundle for production - Issue Unknown provider: eProvider <- e <- treeRightClickDirective
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-tree-control.