2
votes

I have an NSOutlineView that contains multiple columns. How can group node's cells be merged so that i use the extra space for node title? For example, i have "name", "height", "weight" etc. columns for child nodes, but i need the group node to say "beverly hills high scholl's football team" which is too long to fit into one column so i need to expand the frame of that column in the group node.

I've tried to find the answer but all i could find were solutions for NSTableView and they involved subclassing, which NSOutlineView class reference explicitly says you shouldn't do. Next thing that came to mind was using categories to redefine NSOutlineView methods, but once again decided against it after reading up a bit on that online.

Any help is greatly appreciated.

2
Afraid that's not directly supported by the AppKit classes so custom controls might be your only way - Jay
I have to admit that I find the documentation for NSOutlineView a bit wanting, so make sure that you read the header file and docs for the super class NSTableView, too. Oh, and there are things that require you to subclass NSOutlineView. Just make sure you read the docs for the methods you override. - Monolo
Thanks for the answers. I found this mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/… but it deals with NSTableView. I still tried it out, but didn't get any cells to display. Column headers would display properly but the "body" of the table is just blank. - baxus

2 Answers

0
votes

I've followed instructions on http://www.mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/index.html and it worked. The problem with no cells being displayed was caused by an empty drawRect implementation. I deleted it and left it for NSTextfieldCell to handle.

0
votes

If you need to do this for only select nodes (usually the root ones), then try to return a cell (e.g. NSTextFieldCell in your case) for nil column in the method -[NSOutlineViewDelegate outlineView:dataCellForTableColumn:item:] — read more in its discussion and documentation. You then might also want to override [NSOutlineViewDelegate – outlineView:isGroupItem:] for these nodes to return YES for more interesting appearance.