ListboxTV.DataSource_SortRows?

I am using Thomas Tempelmann’s ListboxTV NSTableViewMBS extension on a macOS only desktop project, and besides from my inability to reduce the cells as small as intended (and the textCell seems to be a bit off towards the top of the rows always), I find myself unable to figure out how to handle the DataSource_SortRows method/event. Did someone else succeed? And find where in the class the sort marker gets set incorrectly when user has rearranged the columns too?

I sort the following way: Clicking on the header goes to the databases and changes the sort column. Then new data is loaded.

Let me check if I find my custom code for handling the sort markers. It’s not 100% good but better than nothing.

Gr… Xojo still crashes on Ventura for NSTableView.

Here is the code:

cocoaListbox.SortedColumn = SortOrder.SortColumns(SortOrder.MenuHandlerNames.IndexOf(OrderBy))

dim theCol as NSTableColumnMBS = cocoaListbox.Column(cocoaListbox.SortedColumn)
if theCol <> Nil and Origin = "open" then
  if SortDirection = "ASC" then
    cocoaListbox.TableView.indicatorImageInTableColumn(theCol) = NSImageMBS.imageNamed ("NSAscendingSortIndicator")
  ElseIf SortDirection = "DESC" then
    cocoaListbox.TableView.indicatorImageInTableColumn(theCol) = NSImageMBS.imageNamed ("NSDescendingSortIndicator")
  end if
end if

When the sort marker is ascending and I click on another column then the sort sort marker changes to descending. My code doesn’t catch that.

Thank you, Beatrix! I was hoping for an explanation of SortDescriptors but can adopt that workaround for my project. You can of course change the sort marker irregularity by checking for the current sortDirection of the column and setting it to ascending if direction was none or descending, descending otherwise.

The wrong header index when user has rearranged column order and saved is fixed by replacing line 4 of ListboxTV.didClickTableColumn by
Dim column As Integer = Me.View.columnWithIdentifier(ListColumnTV(tableColumn).identifier), btw.

1 Like