Re: "Select All" first in table view
Re: "Select All" first in table view
- Subject: Re: "Select All" first in table view
- From: "I. Savant" <email@hidden>
- Date: Thu, 10 May 2007 10:11:52 -0400
On 5/10/07, Micha Fuhrmann <email@hidden> wrote:
I need the first entry in the table to be "Select All",and to stay
there while the column is sorted. I've tried inserting a new object
in the array but I can understand why it doesn't want to since it's
pulling it's data from another NSArrayController.
This shouldn't be in the model (an "All" entity, or whatever you
tried) as it has *nothing* to do with your model, only how it's
displayed. This is a job for the controller layer.
I'm going to say something shocking: Bindings doesn't fit every
situation. :-) You'll probably need to use the table data source
methods (there's *nothing* wrong with using them and they're not
necessarily 'inferior' to using an array controller / bindings). I'd
go ahead and use the array controller so you get all the other
benefits (sorting, fetching, filtering, etc. based on bindings), but
use the table data source methods to actually provide the table's rows
since you're adding an additional layer of abstraction (select from
this list of model objects or select the "all" token that isn't actual
data).
In the data source, you could always return the count of the array
controller's content plus one as the -numberOfRows... and when asked
for the object value for table column/row, return your "All"
placeholder for row 0 and the rest would be the -arrangedObjects of
the array controller (which automatically respects the sorting).
You'd have to do some additional wiring to keep stuff in sync when
the contents change or are sorted (perhaps a subclass of
NSArrayController which tells your table's data source (or the table
itself) to reload the table data in its -rearrangeObjects method??).
You just need to keep in mind you're adding an additional layer of
abstraction between the list of model objects and the view that
represents them, so binding the table's columns directly to the array
controller isn't going to work the way you want it to since it doesn't
provide this functionality.
Of course all this can be avoided if your users simply select all
the rows in the table rather than a single row to represent all rows
... I've always had mixed feelings about this approach. :-)
If anyone has a better way, I'd love to hear it!
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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