List question / help

Hi, I was hoping someone might be able to help me with this (probably trivial) problem I am having.

I have a list if items (e.g. a, b, c, d, e) which I have populated into a table in IB. This table is no editable and allows multiple selections. Basically what I am looking to do is when a user clicks a button in my mainWindow (where the table is situated), any selected items from the table are displayed.

My code currently gets the ?ID’s? of the table (i.e. if I select a & b & then click the button - I get 1,2 as a list). My preference would be to get the contents of the rows there and then. If this is not possible I am trying to get a script that will use 1& 2 and match against the original list and return {a,b}

I hope this makes sense and if someone can help me out I would be very grateful

Hi,

I hope I’m understanding correctly…You’re getting the row numbers returned instead of the content of the data from the selected table rows?

Try this and let me know if it works…I’m not at my mac where I can test it, but I think it should work…

set mytabledata to {}
set thesource to data source of table view "thetable" of scroll view "thetable" of window "window"
	set therows to (selected rows of table view "thetable" of scroll view "thetable" of window "window") as list
	repeat with thisrow in therows
		tell theSource
			set thisdata to contents of data cell 1 of data row thisrow
		end tell
		set end of mytabledata to thisdata as text
	end repeat
return mytabledata

If it doesn’t work, post some code and I’ll try to help if I can…

Joe

p.s. I’m probably butchering my references to the table, going the long way about it…

:smiley:

Fantastic - thanks a mil Joe! That was half a days irritation washed away