質問

I'm trying to implement outline view in my app using NSOutlineView, but in my app the outer layer (parent) should have only one column (Brand) and inner layer (children) should have 5-6 columns (Size,Type,Image, etc.).

Is it possible to achieve, and how to do so if it is?!

役に立ちましたか?

解決

Yes, you can have “full-width” cells for “group rows” in a NSOutlineView (or NSTableView).

If you’re using a cell-based outline view, implement outlineView:dataCellForTableColumn:item: in your NSOutlineViewDelegate. Before this method is invoked with any of the existing columns, it will be invoked with a column of nil. For the corresponding rows, return a prototype NSCell, and in your other data source/delegate methods likewise return the corresponding information for a nil “column”. You just need to create a generic NSTextFieldCell for this; no need to style it yourself unless you want to. More information in the documentation or take a look at some Apple sample code.

If you’re using a view-based outline view, implement the equivalent outlineView:viewForTableColumn:item:. Unfortunately the documentation is currently pretty nonexistent, but the corresponding NSTableViewDelegate method is documented, and you can look at this code sample.

The appearance of the full-width item will vary based on the highlight style (selectionHighlightStyle) configured for your outline view; from your description, it sounds like you would want “regular” rather than “source list” behavior.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top