Re: Removing sorting from NSTableView
Re: Removing sorting from NSTableView
- Subject: Re: Removing sorting from NSTableView
- From: Scott Anguish <email@hidden>
- Date: Mon, 19 Jul 2010 01:12:24 -0400
On Jul 18, 2010, at 8:03 PM, Graham Cox wrote:
>
> On 19/07/2010, at 4:10 AM, Gideon King wrote:
>
>> I guess if there isn't already something built in, I may have to either subclass something in the table header and make it three state, or maybe override somewhere in the tableview or array controller where it sets the sort descriptors or perhaps turn off the automatically hidden scrollers and put a button in the cornerView... any suggestions or examples would be appreciated.
>
> There's not really any such thing as an "unsorted" order.
>
I’d disagree. Perhaps in Core Data. But in the case of arrays there can be a natural order.
Gideon’s concern is valid. But as he’s found out, there isn’t a good answer. Subclassing NSTableHeaderView is one option to show three phases (and file a bug, PLEASE). I’ve also in my own app that only I use stuck a view in the view area in the top right corner.
> If the order that you added items to your data set is important, and you want to sort on that, you probably should define a property which is the ordinal of the item as originally created, or timestamp them so you can sort on creation time, etc. Then you have a property on which you can sort to recover that order at any time. You can then add a sort descriptor for it which could either be added to the tableview's sort descriptors - I believe if you add one that doesn't correspond to a column it will still hold onto it for you but it will gradually get pushed to the back of the list as the table is used, but as I found the other week it's probably better to move the sort descriptor handling to your controller (tableview's datasource/delegate) and take that responsibility away from the tableview.
If you can tell me why (off-list) that might be very useful to some doc.
>
> Once you have the sort descriptor handling in the controller, you can easily implement a three-state sorting if you want - the table view merely informs you that the sort order has changed, so you can cycle through different sort descriptors as you wish, and then update the table column headers to match. Easier might be just to have a table column for the original ordinal order so the user can see what they are sorting on instead of working out that there's a third "unsorted" state. iTunes does that for example.
Yes, but some data does just have a natural order that you want to maintain. that you don’t want to add an index number to. But the index insertion is valid. You just may not want to show it, in which case you’re back to square one._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden