开发者

NSTableView setting the sort column?

I have a NSTableView with multiple columns. clicking each of the columns sorts by the column like in iTunes. However when the tableview first loads the rows are unsorted and no tablecolumn is highlighted or displaying the up/down indicator image. I'm wondering if theres a simple way I can programmaticall开发者_运维百科y set the column the table is sorted by and set the indicator image on startup.

The only solution I can think of is using [NSTableView setIndicatorImage: inTableColumn:] and [NSTableView setHighlightedColumn:], but that makes it so that clicking on the header doesnt highlight the column. I would rather not have to use tableView:mouseDownInHeaderOfTableColumn: and rewrite the whole click on header to sort thing.


You might try setting your sort discriptor.

- (void)setSortDescriptors:(NSArray *)array


- (void)windowControllerDidLoadNib:(NSWindowController *) windowController
{
   [super windowControllerDidLoadNib:windowController];
   NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"order" ascending: YES] autorelease];
   [oTable setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
}

http://lists.apple.com/archives/cocoa-dev/2006/May/msg01434.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜