RATreeView
RATreeView copied to clipboard
How can I set all the cells default state to expanded?
Hi, first thank you very much for your RATreeView. I use the latest version 1.0.3,Its default state for all of cells is collapsed,can I change it to expanded the default state?How can I do? Please help,thank you,looking forward to your reply
+1
I am looking for that too ! Thank you.
[_treeView reloadData];
for (id item in [_treeView itemsForRowsInRect:_treeView.frame]) {
[_treeView expandRowForItem:item expandChildren:YES withRowAnimation:RATreeViewRowAnimationNone];
}
OK, I understand, thank you very much.
thank you very much first, i got the code above ,however the treeview expanded with animation still,please helpe
Well done.Thanks.
thank you very much first, i got the code above ,however the treeview expanded with animation still,please help.
+1
I set _treeView.rowsExpandingAnimation = RATreeViewRowAnimationNone; _treeView.rowsCollapsingAnimation = RATreeViewRowAnimationNone;
treeView with animation still.
Something a little better:
- (void)reloadData
{
_treeView.hidden = YES;
[_treeView reloadData];
[UIView animateWithDuration:0. animations:^{
for (id item in [_treeView itemsForRowsInRect:_treeView.frame]) {
[_treeView expandRowForItem:item expandChildren:YES withRowAnimation:RATreeViewRowAnimationNone];
}
} completion:^(BOOL finished) {
_treeView.hidden = NO;
}];
}
Hope it help!
Have a try my way:
id itemBefore = [[_treeView itemsForVisibleRows] firstObject];
[_treeView reloadData];
NSArray *array = [_treeView itemsForRowsInRect:_treeView.frame];
if(array.count > 0){
for (id item in array) {
if ([item isKindOfClass:[DepartmentInfo class]]) {
if ([item isExpand]) {
[_treeView expandRowForItem:item expandChildren:NO withRowAnimation:RATreeViewRowAnimationNone];
}
}
}
[_treeView scrollToRowForItem: itemBefore atScrollPosition:RATreeViewScrollPositionTop animated:NO];
}
I set _treeView.rowsExpandingAnimation = RATreeViewRowAnimationNone; _treeView.rowsCollapsingAnimation = RATreeViewRowAnimationNone;
treeView with animation still.
Each time you modify you RATreeView organise the code responsible for the changes in the way presented below:
[treeView beginUpdates];
//modify your tree view here
[UIView performWithoutAnimation:^{
[treeView endUpdates];
}];
It works for me - I had the same issue with the UITableView
itself.
Dear Augustyniak , Thank you very much!!!!!!! 👍
nice work, thanks you
hello. now im working in swift, can u provide this expand code using swift 4?
i got this problem
how to get indexPathForItem in RATreeview swift version. It's not working