Re: How to force an initial column sort with NSTableView and controller?
Re: How to force an initial column sort with NSTableView and controller?
- Subject: Re: How to force an initial column sort with NSTableView and controller?
- From: John Bishop <email@hidden>
- Date: Thu, 22 Jun 2006 14:01:37 -0500
I think I understand your problem... you already have proper sorting set up
for individual columns in your table (via NSSortDescriptors or otherwise) that
properly sort the table when the column header is clicked, but no way to make
sure the table is in a "beginning" order when first displayed...
You need to use an NSArrayController to designate the table contents, then
bind a sortDescriptor (perhaps retrieved from your editor code) to that
NSArrayController.
That is, you need to set it up so the "raw" table contents from which rows are
displayed are already sorted. Table column clicking will result in its own
sorting activity - sorting the "already sorted" source of the data by its own
criteria. DON'T apply a sortDescriptor to the NSTableView - that seems to
disable column sorting. In fact, you shouldn't need any bindings related to
Table Content for the NSTableView. If I'm not making any sense, write me
off-list and I'll try to send a working sample.
Since the pre-sorting of the "raw" table data is independent of the sorting
criteria for your table columns (ie: you might want the table initially in
chronological order, but none of the column contents designate time), you may
not be able to get the proper column heading "lit" as you specify. In my
experimentation, however, if the data is initially presented sorted according
to the criteria for a column's sort, that column header is indeed "lit" as you
wish. I consider that a nice bonus.
Alexander Lamb <email@hidden> said:
>I actually use this (from IB), the problem is not the sorting which
>works fine, the problem is to trigger the sort automatically when the
>table is loaded (and show the sort triangle in the correct column).
>
>Somehow a function which would say:
>
>- setSortsAutomaticallyOnLoadOnColumnWithIdentifier:@"name"
>
>Alex
>--
>Alexander Lamb
>email@hidden
>
>
>On Jun 22, 2006, at 2:15 PM, I. Savant wrote:
>
>>
>> Check out the documentation for NSTableColumn. Specifically: -
>> setSortDescriptorPrototype: ...
>>
>>
>> On Jun 22, 2006, at 5:18 AM, Alexander Lamb wrote:
>>
>>> Hello list,
>>>
>>> I have a core data application.
>>>
>>> I would like to force the sort on a given column when the data is
>>> loaded in my NSArrayController and displayed in the NSTableView.
>>> Sorting works fine manually (e.g. when clicking on the column
>>> header) so I would like to do as if the used had clicked.
>>>
>>> I know I can sort programmatically the objects in my controller,
>>> but I want to show the visual feedback of my column with the
>>> little sort triangle.
>>>
>>> Thanks,
>>>
>>> Alex
------------------------------------------------------------------
John Bishop <mailto:email@hidden>
Mulligan Software <http://www.mulligansoftware.com>
Mulligan's Golf Personal - Stats & Handicapping for the Mac Golfer
_______________________________________________
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