Why is my treeview not working?
See original GitHub issueHey!
I am trying to plug my own data into the Treeview example.
I have basic company structure that has people that work under people etc.
I want to eventually display it like this:
but for now I cant even get it to work correctly.
all i get in the example is this:
the only real differences between what is there already and what i have are here that i have wrapped strings for the names, and the state is the overall company, which is just a list with a person in it…
module TreeViewDemo =
open WrappedString
type Person = {
FirstName : String50
LastName : String100
CompanyPosition : String100
People : Person list
}
let person = {
FirstName = String50 "new"
LastName= String100 "person"
CompanyPosition = String100 "newPosition"
People = []
}
type Company = {
People: Person list }
type State = {
Company : Company }
//type Taxonomy = {
// Name: string;
// Children: Taxonomy seq
//}
let company = {
Company =
{ People = [
{ FirstName = String50 "Bolt"
LastName = String100 "VanderHuge"
CompanyPosition = String100 "Chief Executive Executionator"
People = [{
FirstName = String50 "Stump"
LastName = String100 "Junkman"
CompanyPosition = String100 "Director Of Fantasticness"
People = [{
FirstName = String50 "Fist"
LastName = String100 "Rockbone"
CompanyPosition = String100 "Director Of Heroism"
People = [{
FirstName = String50 "Butch"
LastName = String100 "DeadLift"
CompanyPosition = String100 "Hero"
People = []};{
FirstName = String50 "Splint"
LastName = String100 "Chesthair"
CompanyPosition = String100 "Mover"
People = []};{
FirstName = String50 "Flint"
LastName = String100 "Ironstag"
CompanyPosition = String100 "Waterboy"
People = []};{
FirstName = String50 "Blast"
LastName = String100 "HardCheese"
CompanyPosition = String100 "Palmreader"
People = []}
]}
]}
]}
]};
}
//let food = { Name = "Food"
// Children = [
// { Name = "Fruit"
// Children = [
// {Name = "Tomato"; Children = []}
// {Name = "Apple"; Children = []}
// ]}
// { Name = "Vegetables"
// Children = [
// {Name = "Carrot"; Children = []}
// {Name = "Salad"; Children = []}
// ]}
// ]}
//type State =
// { noop : bool }
let getFirstName (person:Person) = match person.FirstName with |String50 s -> s
let getLastName (person:Person) = match person.LastName with |String100 s -> s
let getFullName person = String.concat " " [getFirstName person; getLastName person]
let init =
{ Company = company.Company}
type Msg =
| Noop
let update (msg: Msg) (state: State) : State =
match msg with
| Noop -> state
let view (_state: State) (_dispatch) =
DockPanel.create [
DockPanel.children [
TreeView.create [
TreeView.dataItems [company]
TreeView.itemTemplate (DataTemplateView<Person>.create((fun data -> Seq.ofList data.People.Head.People), (fun data ->
TextBlock.create [
TextBlock.text <|getFullName data
]
)))
]
]
]
type Host() as this =
inherit Hosts.HostControl()
do
Elmish.Program.mkSimple (fun () -> init) update view
|> Program.withHost this
|> Program.withConsoleTrace
|> Program.run
what exactly am I doing wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Tree View Menu not working propertly...
I am working on a website that has a Tree View Menu when navigated to sub-pages of the main site. The problem here...
Read more >tkinter Treeview's insert method is not working when ...
I am trying to insert new entry in tkinter Treeview but it's not working and not showing any errors. The following is the...
Read more >TreeView not working as expected when expanding and ...
TreeView with multiple levels not working as expected. ... Expand all tree to have the same as the image (Image step 3). Now,...
Read more >Tree View on Navigation panel not working
Hello,. We have a few methods to rectify this red X. First, try going to the Window tab and click Reset Layout.
Read more >Python Tkinter Treeview
Here is a basic Treeview with tree. ... Watch the column with #0, this column will display in Tree and show the text...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ignore my question I had the answer right, I just need to turn my Json into a recursive tree and it will work.
just closing this… no reason to leave it floating when I’m not working on this any more. thanks for the help!