I have configured a Source List as a sidebar on my app. Problem is when I run it all of the groups are collapsed. How do I fix this?
Yes, an outline view will start with its rows collapsed. (You can configure it to remember the last state, but that doesn't help for the first time and may not be what you want anyway. For example, if you change your program to add more groups.)
You need to add code to expand the rows you want expanded after the outline view has been populated. One place to do this would be in a window controller's -windowDidLoad
method or an override of a view controller's -loadView
method. Also, almost anywhere that you call -reloadData
or -reloadItem:...
with the root (nil
) item.
If the only expandable rows in your source list are the groups — that is, there are only groups and one level of leaf nodes within the groups — then you can do [outlineView expandItem:nil expandChildren:YES]
and that will expand all groups. Otherwise, you need to identify which specific items you want expanded and invoke -expandItem:...
on each.