DataViewListCtrl Sorting

Python 2.7.2, wxPython-cocoa 2.9.2.4

So I was fiddling with various DataView stuff, and I noticed that the columns in a DataViewListCtrl don’t sort the cells in the column lexically.
Instead, when the user attempts to sort by column, the DVLC merely reverses the order by ID.

How do I get the cols in a DVLC to sort properly?

A fellow named John Jackson seemed to have this problem, referenced here (it’s not the main topic of the thread, he mentions it in passing):

http://groups.google.com/group/wxpython-users/browse_thread/thread/8652d5b661e6523e?fwc=2

If a demo is needed, you can add this loop to the DVC_ListCtrl demo in the wxPython Demo (anywhere in the init):

for column in dvlc.Columns:

column.Sortable = True

Thanks,

Daniel

It looks like the DataViewListCtrl is not doing anything for the column sorting itself, and so it is just falling to the default functionality in DataViewCtrl which doesn't have a very smart comparison function. It probably wouldn't be too hard to add some sorting abilities to DataViewListCtrl. Create a ticket for it and maybe somebody will agree and will implement it.

Meanwhile, you can use DataViewCtrl with your own model class with a Compare method. See the DVC_IndexListModel sample in the demo.

···

On 11/4/11 11:35 AM, Daniel Fontaine wrote:

Python 2.7.2, wxPython-cocoa 2.9.2.4

So I was fiddling with various DataView stuff, and I noticed that the
columns in a DataViewListCtrl don't sort the cells in the column lexically.
Instead, when the user attempts to sort by column, the DVLC merely
reverses the order by ID.

How do I get the cols in a DVLC to sort properly?

A fellow named John Jackson seemed to have this problem, referenced here
(it's not the main topic of the thread, he mentions it in passing):
http://groups.google.com/group/wxpython-users/browse_thread/thread/8652d5b661e6523e?fwc=2

If a demo is needed, you can add this loop to the DVC_ListCtrl demo in
the wxPython Demo (anywhere in the __init__):
*for column in dvlc.Columns:*
*column.Sortable = True*

--
Robin Dunn
Software Craftsman

Python 2.7.2, wxPython-cocoa 2.9.2.4

So I was fiddling with various DataView stuff, and I noticed that the
columns in a DataViewListCtrl don't sort the cells in the column lexically.
Instead, when the user attempts to sort by column, the DVLC merely
reverses the order by ID.

It looks like the DataViewListCtrl is not doing anything for the column sorting itself, and so it is just falling to the default functionality in DataViewCtrl which doesn't have a very smart comparison function. It probably wouldn't be too hard to add some sorting abilities to DataViewListCtrl. Create a ticket for it and maybe somebody will agree and will implement it.

Meanwhile, you can use DataViewCtrl with your own model class with a Compare method. See the DVC_IndexListModel sample in the demo.

Since you recommend using a DVC rather than a DVLC, I was wondering.
How do I go about removing data from a DVC? I am trying to implement a search function, and I thought the best way to do this would be to remove the data from the DVC, filter the data, add back in the filtered data.
Unfortunately, I was having problems doing this with a DVC.

Suggestions appreciated,
Daniel

You should just need to remove the items from your data model and then call the model's RowDeleted or RowsDeleted method so all views using the model will be notified of the the change. You should also use similar patterns when adding or changing rows.

···

On 11/4/11 2:31 PM, Daniel Fontaine wrote:

Python 2.7.2, wxPython-cocoa 2.9.2.4

So I was fiddling with various DataView stuff, and I noticed that the
columns in a DataViewListCtrl don't sort the cells in the column lexically.
Instead, when the user attempts to sort by column, the DVLC merely
reverses the order by ID.

It looks like the DataViewListCtrl is not doing anything for the column sorting itself, and so it is just falling to the default functionality in DataViewCtrl which doesn't have a very smart comparison function. It probably wouldn't be too hard to add some sorting abilities to DataViewListCtrl. Create a ticket for it and maybe somebody will agree and will implement it.

Meanwhile, you can use DataViewCtrl with your own model class with a Compare method. See the DVC_IndexListModel sample in the demo.

Since you recommend using a DVC rather than a DVLC, I was wondering.
How do I go about removing data from a DVC? I am trying to implement a search function, and I thought the best way to do this would be to remove the data from the DVC, filter the data, add back in the filtered data.
Unfortunately, I was having problems doing this with a DVC.

--
Robin Dunn
Software Craftsman