wxDataViewCtrl Sorting on Cocoa

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
LarryM
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Jul 31, 2013 12:28 am

wxDataViewCtrl Sorting on Cocoa

Post by LarryM »

In my Mac OS/Cocoa application, I use a wxDataViewCtrl, and I want to be able to sort a table alphabetically by the text in the second column. If I call the SetSortOrder() method for the wxDataViewColumn object for column 0, the table sorts properly according to the text in the first column. If I call SetSortOrder() for the wxDataViewColumn object for column 1, the table still sorts by column 0. Is there any way to make wxWidgets/Cocoa sort a wxDataView by any column other than the first?

Thank You


Larry
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxDataViewCtrl Sorting on Cocoa

Post by Manolo »

When you create a wxDataViewColumn for appending it to the wxDataViewCtrl you can set the flag wxDATAVIEW_COL_SORTABLE.
Or you can use SetSortable() for the wxDataViewColumn.
Then, SetSortOrder() should work
LarryM
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Jul 31, 2013 12:28 am

Re: wxDataViewCtrl Sorting on Cocoa

Post by LarryM »

The wxDataViewColumn::SetSortable() method does not work for columns other than column 0. The table is always sorted on column 0. I already had the Compare() method overridden for my wxDataViewListModel descendent, so I just added a kluge to ignore the column and ascending arguments and use values that I set explicitly because 0 is always passed for the column to the Compare method. This approach seems to have solved my problem. There definitely appear to be some mistakes in the wxWidgets implementation on Cocoa.

Thank You


Larry
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxDataViewCtrl Sorting on Cocoa

Post by Manolo »

You're right. This is a bug, not fixed yet:
http://trac.wxwidgets.org/ticket/15405
Post Reply