ng2-tree icon indicating copy to clipboard operation
ng2-tree copied to clipboard

Allows checkbox for tree nodes

Open kennywk opened this issue 9 years ago • 15 comments

Would be nice if there was a standard way of putting checkboxes and checked events within the tree model.

kennywk avatar Apr 16 '17 10:04 kennywk

Just looking for something like this. [+1 for request]

sovan107 avatar Apr 26 '17 06:04 sovan107

@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.

TKul6 avatar Sep 10 '17 14:09 TKul6

@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.

rychkog avatar Sep 11 '17 10:09 rychkog

Hi,

I started working on the checkbox feature, this is what I have so far:

  • In the Ng2TreeSettings contains 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 TreeController support 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.

  1. 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).
  2. 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.
  3. 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

TKul6 avatar Sep 26 '17 07:09 TKul6

@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.

rychkog avatar Oct 07 '17 15:10 rychkog

@TMaster PRs will allow us to bring this feature to the master much faster

rychkog avatar Oct 07 '17 15:10 rychkog

@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.

omid-nazifi avatar Jan 09 '18 12:01 omid-nazifi

This is exactly what we are looking for. What is the status? Help Needed?

AllNamesRTaken avatar Jan 24 '18 09:01 AllNamesRTaken

There is a pending PR #181 I'm waiting for @rychkog to replay for a designing problem there.

TKul6 avatar Jan 24 '18 12:01 TKul6

Any progress on this?

boban100janovski avatar Feb 01 '18 11:02 boban100janovski

@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 avatar Feb 01 '18 11:02 rychkog

@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?

boban100janovski avatar Feb 08 '18 13:02 boban100janovski

@boban984 There are some comments that need to be fixed - once done - will be merged

rychkog avatar Feb 08 '18 13:02 rychkog

@boban984 I will be working on issues created so far (including checkboxes) on Saturday

rychkog avatar Feb 08 '18 13:02 rychkog

Will start with this feature

rychkog avatar Feb 08 '18 13:02 rychkog