Re: Sorting in an NSTableView
Re: Sorting in an NSTableView
- Subject: Re: Sorting in an NSTableView
- From: Chris Hanson <email@hidden>
- Date: Thu, 10 Jul 2003 19:58:47 -0500
On Thursday, July 10, 2003, at 05:40 PM, Graham Savage wrote:
Newbie Cocoa-Java app programmer.
I have an NSTableView with 3 columns.
I would like to be able to sort on any column, highlight the sorted
column header and draw some indicator in the column header to indicate
sort direction.
Is there anything to assist with this or do I have to listed to clicks
on a header cell and do everything 'manually'?
You have to do everything "manually" but it's not so hard. An
NSTableView will tell its delegate that there was a click on a table
column, and which table column was clicked. It's also very easy to do
things like set an indicator image in a column, highlight a column to
indicate it's the one being sorted, find the currently-highlighted
column, and actually sort the data in your data source.
If you're properly refactoring as you were create your application,
you're likely to wind up with a kiind of "TableController" class that
acts as a table view's data source (and possibly delegate). If you
have or create something like this, you'll be able to add sorting and
highlighting to tables in your application in a fairly generic fashion.
Using the BDSortOrdering class in BDControl would help make the sorting
part trivial if you were doing Objective-C or if there were sufficient
information available on the Java bridge that I could produce a bridged
framework. As it is, it's not all that hard to roll your own
sort-ordering object in Java.
Also, how does one achieve the nice striping on the rows a la iTunes?
Subclass NSTableView.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.