If I have a table view, inside a scroll view with a data source, how the heck do I clear the table? I’ve literally tried everything I can think of, even some things that make absolutly no sence including…
set tableView to table view "devices" of scroll view "devices" of window of theObject
set contents of tableView to {}
or
set contents of myDataSource to {}
I’ve scoured google for over a day now and am still coming up empty handed. Anyone else ran into this and just have a stupid quick solution (as I’m sure that’s what it is, something I am overlooking). =P It’s really startin’ to erk me that I can’t simply update the entire contents of a table view without keeping the old contents!
set theTableView to table view "theTableView" of scroll view "theScrollView" of window "theWindow"
set theDataSource to data source of theTableView
delete every data row of theDataSource
set data source of theTableView to theDataSource
I’m trying to do something very similar, but not quite. Basically I want to replace the data source of a table with an updated array, and of course have the table update.
I’ve successfully populated two tables, each with its own data source. What I want to do is, if the first table changes (with data source: pl_data_source), completely repopulate the second table, and its data source (pc_data_source).
for each table I basically have 3 kinds of variables:
the table itself
the data source of the table (pl_data_source, pc_data_source)
an array of temp data (pl_data, pc_data)
Here’s what I’m trying:
on cell value changed theObject row theRow table column tableColumn value theValue
set pl_data to pl_data_source
– this gets a list of according to whether the corresponding column in a row is checked (check boxes),
– needed for the “initplaylists” handler below it:
getactionplists() of me
– this builds a new temp data array (pc_data), and I want to replace the original pc_data_source
– and of course the table view that shows it, with this new data:
initplaylists() of me
delete every data row of pc_data_source
set pc_data_source to pc_data
end cell value changed
what I get is the following error:
Can’t make last insertion point of data source id 16 into type reference. (-1700)
I found something that worked for me. Maybe it will be of use to others. I wish the documentation on tables and datasources were a lot better, tho.
For the time being, maybe you have an idea about my user defaults question in another thread–which is really bugging me.
on updatepltable()
set pl_data to contents of every data cell of every data row of pl_data_source
initplaylists() of me
tell tab view item “maintab” of tab view “maintabs” of window “main”
tell scroll view “playlistsscroll”
set pl_data_source to data source of (table view “playliststable”)
delete every data row of pl_data_source
append pl_data_source with pl_data
set sorted of pl_data_source to true
set sort column of pl_data_source to data column “podcastpl” of pl_data_source
end tell
end tell
end updatepltable
on updatepctable()
set pc_data to contents of every data cell of every data row of pc_data_source
initpodcasts() of me
tell tab view item “podcasts” of tab view “maintabs” of window “main”
tell scroll view “podcastsscroll”
set pc_data_source to data source of (table view “podcaststable”)
delete every data row of pc_data_source
append pc_data_source with pc_data
set sorted of pc_data_source to true
set sort column of pc_data_source to data column “podcast” of pc_data_source
end tell
end tell
end updatepctable