Open asehmi opened 1 year ago
+1 to this issue, which actually encompasses 2 sub-issues:
checked
argument as a str
(even if it is provided as an int
for instance)checked
argument do not show as checked
in the tree viz. Related IMO is the fact that if you put the tree_select inside an expander, the checked values are preserved but not their display (see code below to reproduce the behavior)import streamlit as st
from streamlit_tree_select import tree_select
nodes = [
{
"value": 1,
"label": "A",
"children": [
{"value": 11, "label": "AA", "children": [{"value": 111, "label": "AAA"}]},
{"value": 12, "label": "AB"},
]
},
{
"value": 2,
"label": "B",
"children": [
{"value": 21, "label": "BA"},
{"value": 22, "label": "BB"},
]
}
]
with st.expander("Expend tree_select"):
return_select = tree_select(
nodes, key="key", checked=[str(n["value"]) for n in nodes]
)
st.write(return_select)
Also adding my support for this issue. If I have the value
set as some string, then pass that string to the checked
property, once I have created the tree, requesting the checked
property back out returns the nodes I would expect to be checked yet as previously stated, they do not appear as checked on the view
Hi,
The
tree_select
checked
property doesn't cause the listed nodes to be visibly selected in the tree, nor expand the branches they are in (depending on theexpand_on_click
setting).Would it be possible to provide the
checked
nodes list in the form they would have been defined, i.e. asdict
objects? It seems they need to be converted to strings, so I need to do something likechecked=[json.dumps(node1), json.dumps(node2), ...]
instead of simplychecked=[node1, node2]
. I get the pre-checked nodes back as values but as stated above the tree nodes don't visibly show as checked.Thanks, Arvindra