Hello,
I was reading the documentation for the tableView and in the example they show how to handle when a row is touched and it returns the event.target.index which I assume is the row number. How can I get the data from the row? Below is the code from the documentation.
I have another question on this. In another post the user Icy Spark gave me this code for adding columns to the rows. How can I get the data for each column when a row is clicked? I added this code for adding the columns below also. I want to show data in multiple columns for each row. then allow the user to click on a row and do something with it.
Thanks! Warren
-- Handle touches on the row
local function onRowTouch( event )
local phase = event.phase
if "press" == phase then
print( "Touched row:", event.target.index )
end
end
local function onRowRender( event )
local row = event.row
local rowGroup = event.view
local halfh = row.height \*0.5
--add first column
row.col1 = display.newText( "Column1: ",50,halfh, native.systemFont, 12 )
row.col1:setReferencePoint( display.CenterLeftReferencePoint )
row.col1.x= 50
row.col1.y = halfh
row.col1:setTextColor( 0 )
--add second column
row.col2 = display.newText( "Column2: ",150,halfh, native.systemFont, 12 )
row.col2:setReferencePoint( display.CenterLeftReferencePoint )
row.col2.x= 150
row.col2.y = halfh
row.col2:setTextColor( 0 )
--add col1 and col2 to the row group
rowGroup:insert( row.col1 )
rowGroup:insert( row.col2 )
end
[import]uid: 184193 topic_id: 37372 reply_id: 67372[/import]