tree := TreeModel new.
tree openWithSpec.
tree columns: (Array
with: (TreeColumnModel new displayBlock: [:node | node content first asString ]; headerLabel: 'Name'; yourself)
with: (TreeColumnModel new displayBlock: [:node | node content second asString ]; headerLabel: 'Last Name'; yourself)
with: (TreeColumnModel new displayBlock: [:node | node content third asString ]; headerLabel: 'Age'; yourself)
with: (TreeColumnModel new displayBlock: [:node | node content fourth asString ]; headerLabel: 'Gender'; yourself)).
tree roots: {
{'Benjamin'.'Van Ryseghem'.'26'.'M'}.
{'Pamela'.'Anderson'.'Far too much'.'F'}
}
Right now, you can get the same by
- adding MorphTreeAdapter>>#columns:
columns: columns
self widgetDo: [ :w |
w columns: columns.
w resizerChanged.
w updateList ]
And then evaluating:
tree := TreeModel new.
tree openWithSpec.
tree columns: (Array
with: (MorphTreeColumn new rowMorphGetSelector: [:node | node item first asString asMorph ]; headerButtonLabel: 'Name' font: nil; yourself)
with: (MorphTreeColumn new rowMorphGetSelector: [:node | node item second asString asMorph ]; headerButtonLabel: 'Last Name' font: nil; yourself)
with: (MorphTreeColumn new rowMorphGetSelector: [:node | node item third asString asMorph ]; headerButtonLabel: 'Age' font: nil; yourself)
with: (MorphTreeColumn new rowMorphGetSelector: [:node | node item fourth asString asMorph ]; headerButtonLabel: 'Gender' font: nil; yourself)).
tree roots: {
{'Benjamin'.'Van Ryseghem'.'26'.'M'}.
{'Pamela'.'Anderson'.'Far too much'.'F'}
}
Ben
Ben, in each cell, can we put something else than a String ? If so, can you add an example in the code above ? Thanks.
I guess doing Ben's solution is the best. I did it with nested layout but it is definitely not as good (see file in attachment, add it in your image then evaluate SpecTable new).