TableView column sort mystery

8 views
Skip to first unread message

Luke

unread,
Feb 1, 2023, 8:04:56 AM2/1/23
to Cappuccino & Objective-J
I have a TableView with column bindings to various fields in an ArrayController, as usual.
As the rows must be presented in a strict order (the one originally from the underlying content array, I have the "Create Sort Descriptor" checkbox in Xcode/IB turned off for all bindings on these columns, which seems to properly suppress the sort arrows on the table header for columns (i.e. when you click in the column heading, no column sorting happens).

Except... the very first column has a binding to a key in the record through which I do a lookup for a status icon (in the binding's transformer).  That works perfectly, but I notice that this binding does not have a "Create Sort Descriptor" option.  However, this column insists on reacting to a click in its header and generating the column sort (on an otherwise pretty useless value to sort on, and indeed messing up the strict order required).

I'm confused as to why this one column in my table has the missing "Create Sort Descriptor" in its binding (but perhaps this has to do with having an image cell in the column).  Moreover, I can't find a way to assert that this column should not try to express a sort when clicked.  

I do not have the sort key/selector values set on any of the column properties.  

I suppose this could be a Cappuccino bug, in which case people may already have had to work around it.  It has crossed my mind that if I set up the sort descriptors binding on the array controller and force the instance of the sort descriptor to overtly sort on the required natural order of the content array, then maybe the table will be prevented somehow from affecting this order.  Or perhaps I'll need to intercept the click on the errant table heading to stop that translating into its attempt to set a sort on this one column.

Luke

unread,
Feb 1, 2023, 1:46:54 PM2/1/23
to Cappuccino & Objective-J
Quick addendum.

The Apple TableView Programming Guide says:
Leaving the Sort Key and Selector fields blank disables sorting of the column using the settings within Interface Builder. However, it does not disable sorting of the column using other techniques.

... and I have left said Sort Key and Selector fields blank for the column that continues to manifest sort affordance.  I'm also not using any 'other techniques' overtly that could cause the column to think it needs to have a sorting behaviour enabled (it is merely configured for an image cell and bound for its value, which includes a transformer to generate the CPImage instance to display, which in all fundamental ways is working fine). 

So, I'm more convinced than ever that this is Cappuccino being 'special' :) 

Still, I'm hoping that someone has either met this before and come up with a good fix or from general experience has a good/efficient work-around suggestion.
My Cocoa-fu leaves a lot to be desired these days, as it has been 14 years since I did this seriously for Mac app development, so I've forgotten many of the clever wheezes you can pull (and of course Cappuccino has it's own differences anyway).  

Keary Suska

unread,
Feb 1, 2023, 2:31:24 PM2/1/23
to objec...@googlegroups.com
Is it a view our cell-based table view? If this is a view-based table view, there should not be any column bindings at all, and sorting is controlled by the column properties and the data source (if used), IIRC. Having column bindings could be confusing Capp.

Otherwise, I am not sure what that could be, as I haven’t experienced this specific issue. I have a table is my current project (view-based) that has sorting disabled, and works as expected.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”
> --
> You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/objectivej/430c7aa8-fe8c-44db-9c14-ef92f82f3de8n%40googlegroups.com.

Luke

unread,
Feb 1, 2023, 8:18:08 PM2/1/23
to Cappuccino & Objective-J
Thanks Keary.  It's cell-based (currently).  Last time I used Capp (>10 years ago) there was some issue with view-based stuff  (not fully implemented, or buggy, I can't remember), so I stuck with cell-based this time as it seemed simpler/safer.  Good to know that the view-based stuff is working well now... at least, that's what I infer from your response.

TBH I was surprised to find that the binding property to create the sort descriptor disappeared on that column (I think it's because of the CPImageCell, rather than it being a CPTextCell) - so maybe that is inducing the different/bad behaviour somehow.  At some point I'll have to try sinking some real time into experimentation.  I was wondering if forcing a sort on the arraycontroller (or somewhere else) as a whole would suppress the discrete column sorting.  Given that such experimentation can be rather unbounded in time though, so I thought it worth sampling the wisdom of the crowd first :)   Given that this is the only column that doesn't seem to 'get the memo' about having sort disabled, it's a minor bug, but I'll have to address it eventually.
Reply all
Reply to author
Forward
0 new messages