react-checkbox-tree icon indicating copy to clipboard operation
react-checkbox-tree copied to clipboard

How to just get the name top level checked box

Open yunusyavuz16 opened this issue 3 years ago • 5 comments

Hello, first of all, thank you for creating this library. I could not find somethin. I have treeview data like

Level1

Level2

Level3

Level4

in that way, when I checked Level 1 the checked property turns out the level4 but it does not give me the level 1 object I have to just display the name of the top object which is checked. In this example that is level 1. How can I obtain just checked box in top or just checked box name which I clicked. If there is an issue about this subject I am sorry I could not find it. Please help me :) Kind regards.

yunusyavuz16 avatar Feb 27 '22 05:02 yunusyavuz16

Could you please help someone how can I keep the state of box which is checked in Level 1 or Level 2? library always gives me the level 4 state.

yunusyavuz16 avatar Mar 02 '22 04:03 yunusyavuz16

@jakezatecky I am in the troulbe I hope I dont bother you can you help me?

yunusyavuz16 avatar Mar 03 '22 13:03 yunusyavuz16

Same issue here !

JeeremB avatar Mar 04 '22 13:03 JeeremB

@yunusyavuz16 You have to store checked data in a temporary array. Then you have to take the difference of checked and temp array and push the difference into temp array. You will get your desired value.

SamdaniAnik avatar Mar 05 '22 03:03 SamdaniAnik

You could set checkModel="all", which will report all of the checked nodes and not just the leaf nodes. This would include "Level 1" in the selected array, assuming that Level 2 and Level 3 each have just one child below and those are all selected, too.

There is no support for checkModel="top" yet, but that is an on-going enhancement.

jakezatecky avatar Nov 19 '22 00:11 jakezatecky