RATreeView icon indicating copy to clipboard operation
RATreeView copied to clipboard

Delegate callbacks did/willCollapseRowForItem

Open eytanbiala opened this issue 11 years ago • 6 comments

When using either:

[treeView expandRowForItem:dataObject];
[treeView collapseRowForItem:dataObject];

the appropriate delegates are not called:

- (void)treeView:(RATreeView *)treeView willCollapseRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView willExpandRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView didCollapseRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView didExpandRowForItem:(id)item

This is needed if you don't want to expand/collapse on cell selection, but instead use an accessory button to do so. Is this by design, and if so, is there a workaround?

eytanbiala avatar Sep 09 '14 17:09 eytanbiala

Yes, it is by design. You don't need information from delegate about row being expanded/collapsed as you are the one who starts cell action by calling expandRowForItem or collapseRowForItem method.

Augustyniak avatar Oct 13 '14 21:10 Augustyniak

Ok, so how can you know when the expand/collapse animation is complete?

eytanbiala avatar Oct 13 '14 21:10 eytanbiala

Ok, I see. I think it is not possible to be informed about the end of the animation using current API.

Why do you need this information? Maybe there is another way to get the result you want to achieve.

Augustyniak avatar Oct 13 '14 21:10 Augustyniak

I needed it because I wanted to use a button instead of the selected row for expanding/collapsing children. I ended up writing my own tree implementation for this.

eytanbiala avatar Oct 13 '14 21:10 eytanbiala

Are there any updates on this? I think it's important to know when the tree view has fully expanded in a scenario where the superview of the tree view needs to respond to the growth in height.

DanielRakh avatar Jul 17 '15 18:07 DanielRakh

I modified expandRowForItem:withRowAnimation method to call delegates in RATreeView.m as follows

- (void)expandRowForItem:(id)item withRowAnimation:(RATreeViewRowAnimation)animation
{
  NSInteger index = [self.treeNodeCollectionController indexForItem:item];
  RATreeNode *treeNode = [self.treeNodeCollectionController treeNodeForIndex:index];
  if (treeNode.expanded) {
    return;
  }
  [self.delegate treeView:self willExpandRowForItem:item treeNodeInfo:treeNode.treeNodeInfo]; // < - -  

  [self expandCellForTreeNode:treeNode withRowAnimation:animation];

  [self.delegate treeView:self didExpandRowForItem:item treeNodeInfo:treeNode.treeNodeInfo]; //<- -
}

This is working fine for me. Same can be done for collapse.

AkshayNG avatar Nov 15 '16 13:11 AkshayNG