dreamRs / shinytreeview

Hierarchical tree input for Shiny apps
GNU General Public License v3.0
41 stars 8 forks source link

Problem with levels of different lengths #17

Closed flash0926 closed 1 week ago

flash0926 commented 2 weeks ago

I have data with different levels. The sample code is as shown below Some data is at level 2, which is the last level I only want to select the data at the last level. How should I modify the code in this case? As shown in the sample code below, I only want to select the level title. image image

flash0926 commented 1 week ago

Use selectable to make_tree can handle this. lapply(tree, function(node) { if (!is.null(node$nodes)) { node$selectable <- FALSE node$nodes <- modify_tree(node$nodes) if(length(node$nodes) == 0){ node$selectable <- TRUE } } else { node$selectable <- TRUE } node })