Is there a way to set the scroll position so after sorting, ObjectListView scrolls to the new position of the row selected before sorting?

Say for example I have a table with a few hundred rows with the two columns: filename, date_last_edit and I’ve selected a particular row. The table is initially ordered by the file_name.

After sorting by date_last_edit would it be possible to “home” into the position of the row that was selected so the user does not have to scroll up and down looking for it?

Hi,

···

On 14/02/2014 09:16, RedHotChiliPepper wrote:

Say for example I have a table with a few hundred rows with the two columns: filename, date_last_edit and I've selected a particular row. The table is initially ordered by the file_name.

After sorting by date_last_edit would it be possible to "home" into the position of the row that was selected so the user does not have to scroll up and down looking for it?

What about using 'EnsureCellVisible' or SelectObject(items[0], deselectOthers=True, ensureVisible=True)

Werner

Hi Werner -

I tried your 2nd suggestion and it works!

selectedItem = self.fileOlv.GetSelectedObject()

self.fileOlv.SelectObject(selectedItem, deselectOthers=True, ensureVisible=True)

How do I bind this to the sort event?

···

On Friday, February 14, 2014 3:38:27 AM UTC-5, werner wrote:

Hi,

On 14/02/2014 09:16, RedHotChiliPepper wrote:

Say for example I have a table with a few hundred rows with the two
columns: filename, date_last_edit and I’ve selected a particular row.
The table is initially ordered by the file_name.

After sorting by date_last_edit would it be possible to “home” into
the position of the row that was selected so the user does not have to
scroll up and down looking for it?

What about using ‘EnsureCellVisible’ or SelectObject(items[0],
deselectOthers=True, ensureVisible=True)

Werner

You can bind like so

from ObjectListView import EVT_SORT

self.fileOlv.Bind(EVT_SORT, self.SortThis)

···

On Saturday, February 15, 2014 1:17:17 AM UTC-5, RedHotChiliPepper wrote:

Hi Werner -

I tried your 2nd suggestion and it works!

selectedItem = self.fileOlv.GetSelectedObject()

self.fileOlv.SelectObject(selectedItem, deselectOthers=True, ensureVisible=True)

How do I bind this to the sort event?

On Friday, February 14, 2014 3:38:27 AM UTC-5, werner wrote:

Hi,

On 14/02/2014 09:16, RedHotChiliPepper wrote:

Say for example I have a table with a few hundred rows with the two
columns: filename, date_last_edit and I’ve selected a particular row.
The table is initially ordered by the file_name.

After sorting by date_last_edit would it be possible to “home” into
the position of the row that was selected so the user does not have to
scroll up and down looking for it?

What about using ‘EnsureCellVisible’ or SelectObject(items[0],
deselectOthers=True, ensureVisible=True)

Werner

Hi,

···

On 15/02/2014 07:17, RedHotChiliPepper wrote:

Hi Werner -

I tried your 2nd suggestion and it works!

        selectedItem = self.fileOlv.GetSelectedObject()
        self.fileOlv.SelectObject(selectedItem, deselectOthers=True, ensureVisible=True)

How do I bind this to the sort event?

what about making it a method and call it with e.g. CallAfter from within the sort event?

Werner

Great suggestion werner, I used wx.Callafter to ensure the scrolling occurs after the sorting is done.

···

On Sunday, February 16, 2014 7:12:10 AM UTC-5, werner wrote:

Hi,

On 15/02/2014 07:17, RedHotChiliPepper wrote:

Hi Werner -

I tried your 2nd suggestion and it works!

    selectedItem = self.fileOlv.GetSelectedObject()
    self.fileOlv.SelectObject(selectedItem, deselectOthers=True,

ensureVisible=True)

How do I bind this to the sort event?

what about making it a method and call it with e.g. CallAfter from
within the sort event?

Werner