Delete a row from Data View

Hi Folks,

in my Application I am using the data view to present some informations! The User should be able
to delete a row.

when I use

set contactIndex to selected row of theObject as number

it is presenting me the index (number) of the selected row.

Does anyone knows how can to delete this row?

Thanks for your time and for your help,

Stefan

Hi Stefan,

adding and deleting a data row is described in the project /Developer/Examples/AppleScript Studio/Table/

Hi Stefan,

thanks for the hint!

I will post the results… :slight_smile:

br

Stefan

Hi Folks,


if name of theObject is "test" then
		try
			set tableView to table view "contacts" of scroll view "contacts" of window of theObject
			set selectedDataRows to selected data rows of tableView
			display dialog "haha"
			if (count of selectedDataRows) > 0 then
				tell window of theObject
					display dialog "hih"
					-- Remove the contact form the data source
					delete (item 1 of selectedDataRows)
					display dialog "hoho"
				end tell
			end if
		end try
	end if


Using this code I am able to delete the requested row, but I get an ugly Applescript error:

Can’t make item 1 of item 0 of {{“In”, “1”, “+4367682007038”, “TtttrfffffhhhiuuuuiiiiOK”}} into type string. (-1700)

The Error pops up before “hoho” - but the row will be deleted… :frowning:

I even tried “delete (every item of selectedDataRows” but this ended up in opening the debugger…

Thanks for your help,

Stefan

Try this,


	if name of theObject is "Delete Row" then
		set Selected_Row to selected data rows of table view "Your_Table_View" of scroll view "Your_Scroll_View" of window "main"
		repeat with r_ow from 1 to length of Selected_Row
			set delete_row to item r_ow of Selected_Row
			delete delete_row
		end repeat
	end if

Dallas