Hi, well, the incomplete documentation of Spec states clearly that you will be receiving two parameters: onAcceptEdition: aBlock "Set the block to execute when cell edition is accepted. `aBlock` receives two arguments: - the element of the table (See `SpAbstractListPresenter>>#items:` - the string entered while editing" acceptAction := aBlock So, when you set beEditable to your column, you can do something like this: items := { #one -> 'one'. #two -> 'two' }. table := SpTablePresenter new addColumn: (SpStringTableColumn title: 'Key' evaluated: #key); addColumn: (SpStringTableColumn new title: 'Value'; evaluated: #value; beEditable; onAcceptEdition: [ :item :newValue | item value: newValue ]; yourself); items: items; open. and then you can edit whatever you want and update your item. Now, since this is a mechanism that has not been used a lot yet in morphic backend, I just discovered and fixed a bug (not in editable tables, but that affects it: https://github.com/pharo-spec/Spec/issues/1263), so if you want to actually use the functionality, you will need to wait until is merged (tomorrow). Esteban On Mar 20 2022, at 10:26 am, Mark O'Donoghue <mark.odonoghue.2010@gmail.com> wrote:
Howdy all
I am making progress with quite a large application which relies heavily on Spec2 ( but Spec2 is such a big learning curve for me â especially given the incomplete documentation⦠ð)
I am currently struggling with the following issue: I have a SpTablePresenter which shows a collection of domain objects (subclassed from Model). The domain object are instances of âAssetâ which is a relatively simple class. The table works fine.
Now, I need to be able to update some columns , but I donât think I want to build a separate form for doing classic CRUD operations. (There is no need for create or delete functionality â so an in-situ update seems desirableâ¦).
Iâve made a start using SpStringTableColumn >> beEditable and #onAcceptEdition:
But I canât see how to work out what row and column has changed, and how I can update the corresponding Asset instance(s). It thought it would be handled using #whenModelChanged: but there are models in many places (and at several levels in the Spec hierarchy)⦠Iâve tried following it all the way down to the adapters and morphs but I canât see how the freshly edited cell interacts with the model or announcements.
(BTW - It doesnât look like the âselected itemâ features are appropriate since you can do edits in other rows regardless of what row is/isnât selected.)
Is there a correct and/or elegant way to detect these cell changes in a SpTablePresenter and apply them to my domain objects�
Cheers Mark
From: Mark O'Donoghue <mark.odonoghue.2010@gmail.com> Sent: Sunday, 4 July 2021 5:26 PM To: pharo-users@lists.pharo.org Subject: Question about Spec2 and SpTablePresenter
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