stam wrote: ↑Mon Nov 28, 2022 6:44 pm
mrcoollion wrote: ↑Mon Nov 28, 2022 5:36 pm
Using a data grid makes it possible to hide a column.
yes it does, and would be my go-to method as well - but I imagined that option was already disregarded when posing the question...
I was looking for something that was "lighter weight" than a data grid to display a simple list. A table field seemed like the best option (at the time). I may consider a DG at some future time. At the moment I am focused on trying to get what is working now into a beta test.
stam wrote: ↑Mon Nov 28, 2022 6:44 pm
In my mind the
real question is
why do you need to hide the column?
The column is just the array key, and is of no value to the end user. Unnecessary visual clutter is one way to think of it.
stam wrote: ↑Mon Nov 28, 2022 6:44 pm
If it's just to ensure data for the row is accessible but not displayed (eg a primary key in a database), why not store the full TSV text in a custom property of either the tableField, card or stack, and instead use this to populate the tableField, then just referring to the custom prop by line number to get the 'hidden' column(s)?
I'm not sure that approach buys you much. The data is in an array. We combine by return and tab and then sort (by the first column) to get the array in the correct order for the table. Then...
Code: Select all
-- move the first item of each line into item 8, moving everything else left by one position
set itemdelimiter to tab
repeat for each line theLine in gUserdefinedFolderArray
put item 2 to 8 of theLine & tab after newArray -- items 2-8 move to positions 1-7
put item 1 of theLine & return after newArray -- the row number/array key moves to col 8 (used for Reset)
end repeat
delete the last char of newArray
put newArray into field "userDefinedBookmarkFolders"
To reset, sort lines of field "userDefinedBookmarkFolders" numeric by item 8 of each
What I think you are preposing would be something like...
Code: Select all
set the uSortedArray of this stack to gUserDefinedFolderArray -- put it into a custom property
set itemdelimiter to tab
repeat for each line theLine in gUserdefinedFolderArray
put item 2 to 8 of theLine & return after newArray -- items 2-8 move to positions 1-7
-- put item 1 of theLine & return after newArray -- don't need this anymore, going to use custom property to reset
end repeat
delete the last char of newArray
put newArray into field "userDefinedBookmarkFolders"
So that part is basically the same except we copy the sorted list to a custom property and instead of moving column 1 we just overwrite it.
However, when it comes to reset then you have to resort to something like...
Code: Select all
put the uSortedArray of this stack into temp
set itemdelimiter to tab
repeat for each line theLine in temp
put item 2 to 8 of theLine & return after newArray -- items 2-8 move to positions 1-7
end repeat
delete the last char of newArray
put newArray into field "userDefinedBookmarkFolders"
However, there is an argument to say why do you need to reset? Good point, I don't really, and if I gave it up the 2nd option would work just fine without even needing to put it into a custom property (after all, Quit without Saving and then re-opening the file again is a good and common way of throwing unwanted changes away).
Also, if I am missing something obvious here (or a shortcut) please let me know.
Thanks
Mark