Comments (6)
Hi @ismirsehregal
Why did you close? Currently there's no way, I think.
from jstreer.
I wanted to realize a collapsed, but selected tree and thought a selection initially causes the tree to expand. However, this behaviour was caused by a misconfiguration. Actually it does what is expected (see below example).
For the future: If I'd like to try options like this, can this be injected via htmlwidgets::onRender
? Otherwise it might make sense to allow the user passing a list of options. What do you think?
library(jsTreeR)
nodes <- list(
list(
text = "RootA",
state = list(loaded = TRUE, opened = FALSE, selected = TRUE, undetermined = FALSE),
type = "root",
children = list(
list(
text = "ChildA1",
state = list(loaded = TRUE, opened = TRUE, selected = TRUE, undetermined = FALSE),
type = "child",
children = list(list(text = "ChildA12",
state = list(loaded = TRUE, opened = TRUE, selected = TRUE, undetermined = FALSE),
type = "child"))
),
list(text = "ChildA2",
state = list(loaded = TRUE, opened = TRUE, selected = TRUE, undetermined = FALSE),
type = "child")
)
),
list(
text = "RootB",
state = list(loaded = TRUE, opened = FALSE, selected = TRUE, undetermined = FALSE),
type = "root",
children = list(
list(text = "ChildB1",
state = list(loaded = TRUE, opened = TRUE, selected = TRUE, undetermined = FALSE),
type = "child"),
list(text = "ChildB2",
state = list(loaded = TRUE, opened = TRUE, selected = TRUE, undetermined = FALSE),
type = "child")
)
)
)
types <- list(root = list(icon = FALSE), child = list(icon = FALSE))
jstree(nodes,
types = types,
checkboxes = TRUE)
from jstreer.
I think this is not possible with htmlwidgets::onRender
, because the options are applied when one initializes the tree.
Indeed, one could allow the user to pass a list of options. Then in the JS one would do:
options.core = {
data: x.data,
multiple: x.multiple,
check_callback: x.checkCallback,
themes: {
name: x.theme,
icons: true,
dots: true,
responsive: false
}
};
$.extend(options.core, x.options);
But this would require that the user knows exactly what he does.
from jstreer.
I think this would be a good option as long as we keep the current defaults and mark the parameter as "advanced" in the description.
from jstreer.
Hi @ismirsehregal
I added an argument coreOptions
. This is on master.
jstree(nodes,
types = types,
checkboxes = TRUE,
coreOptions = list(expand_selected_onload = FALSE)
)
from jstreer.
Great - thanks Stéphane!
from jstreer.
Related Issues (20)
- Are there any examples of jsTreeR where the user can save/download a tree structure and later retrieve it/upload it into an active session? HOT 3
- jstreeDestroy updates in shiny HOT 2
- [feature request] updateTree HOT 5
- jstreeOutput is not re-rendered in shiny HOT 9
- Use in shiny package development HOT 5
- jsTree not updating when using `uiOutput()` HOT 9
- input[["mytree_full"]] is not updated on expanding a node HOT 4
- overlapping nodes HOT 5
- FR: tie_selection setting HOT 51
- Misaligned grid if search is activated HOT 23
- Error in browser console when using the grid parameter HOT 23
- Pass undetermined state to input$treeID_full HOT 8
- input[["mytree_full"]] is not updated on renaming a node HOT 2
- Error when using custom contextMenu HOT 1
- jsTreeCopied Event not recorded HOT 4
- jsTreeDeleted Event not recorded
- Reordering node under root HOT 1
- jsTreeR affects other htmlwidgets' styling HOT 2
- jsTreeR disables reactive callbacks from bslib nav containers HOT 5
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 jstreer.