Allows checkbox for tree nodes
Would be nice if there was a standard way of putting checkboxes and checked events within the tree model.
Just looking for something like this. [+1 for request]
@rychkog If you want, I'll be happy to start browsing the source code and check how to do that.
This feature will be helpful for me as well.
@TMaster sure, go ahead! I don't have enough time for adding new stuff these days. If you'll have any questions - feel free to ask.
Hi,
I started working on the checkbox feature, this is what I have so far:
- In the
Ng2TreeSettingscontains another parameter enableCheckboxes which is false by default. switching this flag to true will show a checkbox next to any node. - The tree components exposes additional 2
EventEmitters: nodeChecked and nodeUnchecked, when checking \ unchecking node the relevant events are emitted with the node data. - The
TreeControllersupport checking \ unchecking the node.
@rychkog I had to pass the settings object to every node in order to pass the enableCheckboxes property. What do you think about that? is there risks in doing that?
Change is here
All the changes are here I added to the demo additional buttons to check \ uncheck nodes.
The next thing I want to do is to support father-child relations, and for that I need your opinion on how to develop that:
Let's take the Fonts tree in the demo for example.
- If the user checks a branch (Slab serif for example), all his descendants will be also checked (and relevant events will be emitted for each node).
- If a user unchecked a font inside this branch the Slab serif node's state will be undetermined (not sure if event should be emitted in that case, and if so what type). In addition all the ancestors of Slab serif will also be in undetermined state.
- if the Slab serif node will be unchecked all his descendants will be automatically unchecked (and relevant events will be emitted for each node).
What do you think?
Thanks, TMaster
@TMaster Just do a PR - it will be easier for us to work on this feature. According to undetermined state - we can have 3 types of state for a tree with checkboxes - CHECKED, UNCHECKED, UNDETERMINED. That's it. Events should be emitted in a way you described + undetermined event for Parents with partially checked children.
@TMaster PRs will allow us to bring this feature to the master much faster
@rychkog @TMaster Could you tell me that this feature has brought to the master or not? I installed the latest version of ng2tree but i didn't access it.
This is exactly what we are looking for. What is the status? Help Needed?
There is a pending PR #181 I'm waiting for @rychkog to replay for a designing problem there.
Any progress on this?
@TMaster @boban984 I'm back - had a massive amount of work and no chance to work on the tree. Sorry about that. Will start gradually working on issues and resolving checkboxes feature is the first thing I'll do.
@rychkog do you have an estimate of when you will be able to merge the pull request for the "Checkbox" feature? Or maybe it's better to fork the repo and add it?
Maybe i can help out somehow?
@boban984 There are some comments that need to be fixed - once done - will be merged
@boban984 I will be working on issues created so far (including checkboxes) on Saturday
Will start with this feature