Augustyniak / RATreeView

Library providing easy-to-use interface for displaying tree structures on iOS and tvOS.
MIT License
2.49k stars 466 forks source link

Is there any way to expand the all cells ? #239

Open JoleneLiu opened 6 years ago

Maxatma commented 6 years ago
        vm.topLVL.forEach { (item) in
            treeView.expandRow(forItem: item)
        }
JoleneLiu commented 6 years ago

thank for @Maxatma , I've had the fix issue in this way .

Dirk- commented 6 years ago

For Objective C (fits with RATreeViewBasicExample):

for (id item in self.data) {
        [self.treeView expandRowForItem:item expandChildren:TRUE withRowAnimation:RATreeViewRowAnimationLeft];
    }

If you just call expandRow the children will not get expanded.

Kirow commented 6 years ago

Is it possible to apply this w/o animation?

I've tried

tableView.reloadData()
for item in items {
    tableView.expandRow(forItem: item, expandChildren: true, with: RATreeViewRowAnimationNone)
}

but I have animation any way. I want something like reloadDataExpandAll() Does it possible with current source code?

UPD: found working solution in another issue discussion:

tableView.reloadData()
tableView.beginUpdates()
for item in items {
    tableView.expandRow(forItem: item, expandChildren: true, with: RATreeViewRowAnimationNone)
}
UIView.performWithoutAnimation {
    tableView.endUpdates()
}