• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Table view active sorting and filter as model changes...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Table view active sorting and filter as model changes...


  • Subject: Re: Table view active sorting and filter as model changes...
  • From: "Shawn Erickson" <email@hidden>
  • Date: Wed, 23 May 2007 14:03:24 -0700

On 5/23/07, mmalc Crawford <email@hidden> wrote:

On May 23, 2007, at 12:34 PM, Shawn Erickson wrote:

>> How do you get an table view that is bound to array controller that
>> is
>> connected with a model that is modified in a KVO compliant fashion to
>> automatically resort itself or refilter itself as the model changes?
> So based on not getting any response I assume that I haven't missed a
> framework feature that does this automatically for me.
> I guess I need to ask the array controller to rearrangeObjects when I
> know a property has changed that affects sort order... humm now how to
> do that in a reasonable way.
>
You can observe the values that would affect sort order...
(Hint: there may be a subclassing opportunity...)

I see that NSTableBinder is used to get table view cells updated... I guess that the table binder triggers table cell updating to take place hopefully via standard subclass-able NSTableView method so in a subclass of NSTableView I may be able to trap that a cell was updated (redrawn) and use that as a trigger to ask the array control to rearrangeObjects if the cell's column is related to a key in the active sort descriptor.

...or as you state I could iterate over all participants and observe
the key(s) that are currently in the active sort descriptor. Of course
I hate to double the observing that is already taking place so I will
try to piggy back on table binder if I can in a supportable way (not
dependent on implementation details).

The problem, though, is that in general the table view won't know how
a model has changed.

I was more hoping and thinking that NSArrayController would be able to take care of this itself given that it knows the sort descriptor and filter predicate that is currently active and the set/array of objects it is managing. Having NSArrayController deal with it would allow various view objects (and even non-view objects) to benefit from this feature.

This auto feature of course would need to be turned on/off (likely
default to off) for cases like the following and in cases that
performance was an issue.

Thinking a little more about it... subclassing NSArrayController may
be the better way to go. I could have a subclass that observes the set
objects it manages for the keys that are in the active sort descriptor
(filter predicate is a little more complex issue to deal with...).
When the set is mutated and/or sort descriptor changes I would modify
my observations and when a key changes that affect sorting I would
rearrange objects (possibly with a pending delay to aggregate bulk
changes).

 Although what you're proposing may be reasonable
if, say, someone changes a value in a detail field or if a value is
changed by an Apple Script, what happens when a user edits a value in
a table view that causes the row to be re-sorted or worse removed...?
Typically that's likely to provide a poor experience.

Yeah in my case I am not trying to support in table editing so the issue you outlined is a concern in this particular case.

-Shawn
_______________________________________________

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


  • Follow-Ups:
    • Re: Table view active sorting and filter as model changes...
      • From: mmalc Crawford <email@hidden>
References: 
 >Table view active sorting and filter as model changes... (From: "Shawn Erickson" <email@hidden>)
 >Re: Table view active sorting and filter as model changes... (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: How do I make a singleton object AppleScriptable?
  • Next by Date: Re: Table view active sorting and filter as model changes...
  • Previous by thread: Re: Table view active sorting and filter as model changes...
  • Next by thread: Re: Table view active sorting and filter as model changes...
  • Index(es):
    • Date
    • Thread