EDIT - Please skip to the last (most recent) post in this thread to see the relevant problem.
Short version: What is the NSOutlineView's equivalent of NSTableView's noteNumberOfRowsChanged(), in order to reflect nodes being added/removed ?
(noteNumberOfRowsChanged() has no effect on NSOutlineView) i.e. what is the most optimal way to partially refresh an NSOutlineView in response to a change in its model ?
Long version:
Hello, I have a hierarchical view in an NSOutlineView. It is 2 levels deep, below the (imaginary) root node, i.e. there may be multiple expandable items at the top level (i.e. just below the root), and any number of child nodes at most one level down. This is illustrated in the example image below:
Items may be added, removed, or updated over time, in response to user actions. The total number of items can be as large as a few hundred or even a 1000 (there is no constraint). In other words, calling reloadData() each time a node is added is really not an (good) option.
How do I partially refresh this NSOutlineView, in response to a single new top-level row being added ? Let's say I added a new name "Ralph" at the top level. What would be the most efficient/optimal way to refresh the NSOutlineView to get "Ralph" (and his child nodes) to show up ?
In an NSTableView, this is easily achieved through noteNumberOfRowsChanged(). But, that method seems to have no effect on the NSOutlineView. I really do not want to call reloadData() every time a node is added, as it is not optimal in terms of performance.
I'm aware of reloadItem() but this doesn't help for new items being added to the root. Calling reloadItem() on the root node is equivalent to reloadData(), so it doesn't help me.
Thanks !
Short version: What is the NSOutlineView's equivalent of NSTableView's noteNumberOfRowsChanged(), in order to reflect nodes being added/removed ?
(noteNumberOfRowsChanged() has no effect on NSOutlineView) i.e. what is the most optimal way to partially refresh an NSOutlineView in response to a change in its model ?
Long version:
Hello, I have a hierarchical view in an NSOutlineView. It is 2 levels deep, below the (imaginary) root node, i.e. there may be multiple expandable items at the top level (i.e. just below the root), and any number of child nodes at most one level down. This is illustrated in the example image below:
Items may be added, removed, or updated over time, in response to user actions. The total number of items can be as large as a few hundred or even a 1000 (there is no constraint). In other words, calling reloadData() each time a node is added is really not an (good) option.
How do I partially refresh this NSOutlineView, in response to a single new top-level row being added ? Let's say I added a new name "Ralph" at the top level. What would be the most efficient/optimal way to refresh the NSOutlineView to get "Ralph" (and his child nodes) to show up ?
In an NSTableView, this is easily achieved through noteNumberOfRowsChanged(). But, that method seems to have no effect on the NSOutlineView. I really do not want to call reloadData() every time a node is added, as it is not optimal in terms of performance.
I'm aware of reloadItem() but this doesn't help for new items being added to the root. Calling reloadItem() on the root node is equivalent to reloadData(), so it doesn't help me.
Thanks !
Last edited: