Cheers,

From what code you provide I can not spot any error. I do not use your 
persistence strategy myself, so I first thought that it might be an issue 
related to that - for instance something with the identity of objects from the 
recentFileList and the savedEntry messing up. But that would not explain why it 
works unsorted.

I have a piece of code in my application which is doing pretty much the same:
        selected := table selection selectedItem.
        table items: self sheeps.
        (selected notNil and: [ table items includes: selected ]) 
                ifTrue: [ 
                        table selection selectItem: selected.
                        self announceNewSelection: selected ].
For some reason I work on the selection rather than the table, but it does not 
seem to make any difference when I just tried.

Is there a way in which you mock the “objects := ….” to something which do not 
use persistence to rule out that is the persistence causing the problems (or 
verify it). A method which returns a triple of known objects perhaps.

Sometimes the problem lies in the instantiation of the table, so perhaps that 
might help to see.

I am on EU time and on discord this morning, you are more than welcome to try 
to grab me. I have been using SpTablePresenter a lot (and is often baffled as 
well).

Best,

Kasper

> On 4 Jul 2021, at 11.26, Mark O'Donoghue <mark.odonoghue.2...@gmail.com> 
> wrote:
> 
> Howdy all
>  
> I’ve got stuck trying to manage Tables – over 12 hours now and I’m out of 
> ideas!. ☹
>  
> Any observations / suggestions  are most welcome…
>  
> I’ve been loading small external files of transactions using NeoCSV into 
> Spec2 tables.
> I am trying to use Fuel to persist the table contents so that my application 
> will re-load the working state from where I finished in the last session.
> (I’ve opted for Fuel as a simple alternative to having to do the whole object 
> relational mapping thing.)
>  
> The idea is that transactions (and potentially some manual adjustments) will 
> be processed over time.
> (This is preferable to having to reload all files from the beginning evert 
> time I run the application…)
>  
> The Spec2 tables have been working well until I tried to persist them. 
> I can’t seem to fully re-load them to a previously saved state.
>  
> For example - I can restore the essential contents of my table  in most 
> circumstances using: 
>  
> restoreObjects
>                 “filePresenter1 is a SpTablePresenter”
>  
>                 | objects savedEntry |
>                 objects := CpPersist restoreObjectsFromFileNamed: 
> 'E:\Me\zzzST-Test\demo.fuel'.
>                 
>                 recentFileList                     := objects at: 1.
>                 currFileFilter                       := objects at: 2.
>                 savedEntry                          := objects at: 3.
>                                                 
>                 self updateFilterButton: currFileFilter.
>                 
>                 filteredFileList := self filterFilesUsing: currFileFilter. 
>                 
>                 filePresenter1 items: filteredFileList.
>                 
>                 savedEntry 
> ifNotNil: [filePresenter1 selectItem: savedEntry ].
>  
>  
> However, if any of the table columns are re-sorted , the re-load operation 
> gets confused and I can’t get the saved a saved selected item to become 
> selected again.
>  
> (It seems to be confusing the index numbers of the sorted and unsorted lists 
> – even when I match by contents rather than index.)
> (I also created an equality test to ensure equivalent entries are recognised 
> by the #= operation in the list of the underlying model ).
>  
> This all works fine - unless I sort a column!
>  
> Since this approach was going to be used on several screens I’d really like 
> to find a solution.
>  
> Cheers
> Mark
> Perth, Western Australia

Reply via email to