Re: How to save TableView's highlighted column & sort order?
Re: How to save TableView's highlighted column & sort order?
- Subject: Re: How to save TableView's highlighted column & sort order?
- From: Lee Morgan <email@hidden>
- Date: Wed, 29 Jun 2005 00:21:54 -0400
First let me say sorry for the cross post, but I wanted this in the
archives so that (hopefully) it will help others in the future.
I've found (at least in Tiger) that saving a column sort order is
_really_ easy.
Well, at least really easy if your using bindings and a
NSArrayController for your table.
All that is needed is to set up a sort descriptor...
NSSortDescriptor *sorter = [[NSSortDescriptor alloc]
initWithKey:@"ibIdentifier" ascending:YES selector:@selector
(compareSomeBoundValue:)];
And set the array controller's sort descriptor to your newly created
one.
[arrayController setSortDescriptors:[NSArray arrayWithObject:sorter]];
The table will update itself to show if it's ascending or descending
and highlight which column is need in the NSTableView.
Also (I haven't tried) but seeing that NSSortDescriptor conforms to
the NSCoding protocol it can probably be saved to a plist for very
easy preference sorting.
If thats the case it would beg the question as to why this isn't auto-
saved along with column width and ordering?
Thanks to Adam and Marc for helping me though this (seemingly mind
boggling) problem.
- Lee
P.S. Kudos to the teams at Apple that make this stuff "just work."
Good times.
On Jun 28, 2005, at 11:42 PM, Lee Morgan wrote:
Well best I can tell it has to be done "manually."
That is by highlighting the header, displaying the needed
ascending / descending image and sorting the data.
I can get all of this working expect that the indicator image is
draw in the wrong place.
It appears about 12 pixels to the left of where it should be.
And I don't see any method to display it in the correct place.
- Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden