According to the reference above, a data source can be displayed as sorted, but the actual data is still in the order in which it was entered.
I need the data within the data source to be in the same order as it is displayed in the table it is connected to. I will be changing the information (adding new, updating existing, and deleting existing data). I will also be drag-and-dropping this data into other tables/outlines. How can I get the data in the data source to match the order that it is displayed? Any thoughts appreciated.
on will open theObject
set theDataSource to data source of table view "x" of scroll view "x" of theObject
tell theDataSource
make new data column at the end of the data columns with properties {name:"x1", sort order:ascending, sort type:numerical, sort case sensitivity:case sensitive}
make new data column at the end of the data columns with properties {name:"x2", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
end tell
set sorted of theDataSource to true
set sort column of theDataSource to data column "x1" of theDataSource
return
end will open
I have done what you show in your example. The problem is that even though the data is appears sorted in the table, the actual is in it’s original order, ex.: if I enter data in the following order
dfe
abc — the data as entered into the data source
ghi
abc
def — the data as it appears in the table
ghi
If I click on the 2 row, I would expect to get “def” (as shown in the second set), however what I get is “abc” (as shown in the first set).
It occurred to me yesterday (after I posted) that I will need to pull the data out of the data source, sort it and put it back into the data source. Fortunately, I will have less than 50 entries, so sorting will be quick.
Ah, bad news again. For large tables this could be very slow… (reminds me of someone saying AppleScript is easy for the things it can do, but extremely hard for the others)