Set Cell Value of Table Problem

The following code works to create the proper amount of rows for a table view and, according to the log, appropriately sets the contents of the cells to the desired content but when the table is finally displayed, the rows are there but all of the cells are blank. Can anyone see a problem with this code?

Thanks,
Jon

on awake from nib theObject
	set cell_values to {"A", "B", "C"}
	tell theObject
		set theDataSource to data source of table view "x" of scroll view "x"
		tell theDataSource
			make new data column at the end of data columns with properties {name:"name"}
			repeat with cell_value in cell_values
				log ("adding new row with value " & (contents of cell_value) & " to table view "x" of scroll view "x"")
				set theRow to make new data row at the end of data rows
				set contents of data cell "name" of theRow to ((contents of cell_value) as string)
				log ("contents of data cell "name" of theRow: " & ((contents of data cell "name" of theRow) as string))
			end repeat
		end tell
	end tell
end awake from nib

Most of times I found this problem, you miss a name identifier in Interface Builder’s applescript properties. Check the following:

  • Open the applescript info tab in Interface Builder.
  • Click your table and make sure the “NSScrollView” has a name.
  • Double-click the table and make sure the “NSTableView” has a name.
  • Now click the header of the table and make sure the “NSTableColumn” has a name, too.

I usually give the same name to all the elements (unless there are several columns, when I assign unique names to every column), so I can call them more easilly.

Sure enough, I missed the NSTableColumn AppleScript name. It’s working well now, thanks.

Jon

I have been having similar problems with a project that I am working on. I have verified (more than once :frowning: ) that “NSScrollView” has a name, “NSTableView” has a name, each of my “NSTableColumns” have a name (there are 3 and each has a unique name). The NSScroll- and NSTable- Views have the identical name. I have also verifed (again, more than once :? ) that each of the NSTableColumns has the same name in the “identifer” field under that atributes pane (cmd-1). I STILL haven’t been able to get any data to show in my table. :cry: Any other suggestions as where I should look?

Thanks in advance,
Brad Bumgarner, CTA

Have you verified that you receive a value, though you can’t see anything displayed, when asking for it to the table, as in Jonathan’s code?

log ("contents of data cell "name" of theRow: " & ((contents of data cell "name" of theRow) as string))

Anyway, you can take-a-look/duplicate-and-fit-to-your-needs the projects shown at:
/developer/examples/applescript studio/table
and
/developer/examples/applescript studio/table sort

I have logged the contents of the data source and it is filled each data cell is filled with “” (in other words, nothing).

I have pulled heavily from Table Sort. I will look at Table as well.

Thanks,
Brad Bumgarner, CTA

jj,

Thanks for your help. I reworked my app based on Table.app. I first set my script up based on TableSort.app. TableSort.app works fine, but I could NOT get mine to work at all. :?

Thanks again,
Brad Bumgarner, CTA