Tableviews - Accessing Objects Inserted into a Row

I have a tableview that contains images and text. When you tap on the thumbnail, it transitions to a screen where you can see the full image and information specific to that image. When the user makes updates on this screen, I want that information to get updated in the tableview accordingly.

Using tableView._view._rows[i]._view, I get a table of row data including the text objects but can’t find the images or a display.group that I inserted. I need the ability to update these items but can’t find them to make the updates.

I’ve read the tableView documentation and the tutorials, but no luck.

Here is a sample of what my code looks like:

local function updateInfo ( event )     -- code that updates the web server and information on the currennt     -- screen is here, stripped out to keep the forum post simple     -- here is where I was thinking it made sense to update the tableview     -- Assuming I've already identified the correct row, I then     -- want to update corresponding data in the table view for the     -- image I'm currently viewing.          -- below is the code I've been using to try and locate     -- where images are kept that have been inserted into a row     -- I get a lot data including the text objects in the tableview     -- but cannot find the images and display groups that have been     -- inserted into the row.     -- Once I locate them, I assume I'll have to re-render the row?         local rows = myList.\_view.\_rows         for i=1, #rows do             local newRows = rows[i].\_view                 if (newRows ~= nil and type(newRows) == "table") then                     for key,value in pairs(newRows) do                         print( key, value )                     end                 end         end end local function viewFullImage (event)     if (event.phase == "ended") then            local \_fileName = event.target.name                  local newGroup = display.newContainer( screenW, screenH )         newGroup:translate( displayCenterX + newGroup.width, displayCenterY )         local fullImg = display.newImage( \_fileName, system.TemporaryDirectory )         newGroup:insert( fullImg )         local details = event.target.details         local imgInfo = display.newText ( details, 0, 0, system, 35 )         imgInfo:setFillColor( 1, 0, 0 )         imgInfo.x = newGroup.width \* -0.45         imgInfo.y = displayCenterY         newGroup:insert( imgInfo )         imgInfo:addEventListener( "tap", updateInfo )         local goBack = display.newText ( details, 0, 0, native.systemFont, 35 )         goBack:setFillColor( 1, 0, 0 )         goBack.x = newGroup.width - goBack.width         goBack.y = goBack.height \* 2         newGroup:insert( imgInfo )         goBack:addEventListener( "tap", backToTableview )         transition.to( myList, { x = - myList.contentWidth, time = 400, transition = easing.outExpo } )         transition.to( zoomGroup, { x = displayCenterX, time = 400, transition = easing.outQuad } )         end     return true end

If you look a our Business App Sample on github:  in feed.lua you will see how I add the display objects for the row into the row, not only inserting them into the group, but also added it to the row as a new row member.  If you can get to the row object, then you can get to the row items.

Rob

Hi Rob,

I was using the below for my images and display groups.

…onRowRender function…

local row = event.row

row.textA = …

row.textB = …

row:insert(row.textA)

row:insert(row.textB)

img1 = …

row:insert(img1) – by updating this to row.img1, I’m now able to find the images in the row table.

I wasn’t including the “row.” in front of the display objects/groups. I though by doing row:insert, I was accomplishing the same thing.

Hopefully this is helpful to someone else down the line.

Anyways, thanks Rob.

Cheers,

Jeremiah

If you look a our Business App Sample on github:  in feed.lua you will see how I add the display objects for the row into the row, not only inserting them into the group, but also added it to the row as a new row member.  If you can get to the row object, then you can get to the row items.

Rob

Hi Rob,

I was using the below for my images and display groups.

…onRowRender function…

local row = event.row

row.textA = …

row.textB = …

row:insert(row.textA)

row:insert(row.textB)

img1 = …

row:insert(img1) – by updating this to row.img1, I’m now able to find the images in the row table.

I wasn’t including the “row.” in front of the display objects/groups. I though by doing row:insert, I was accomplishing the same thing.

Hopefully this is helpful to someone else down the line.

Anyways, thanks Rob.

Cheers,

Jeremiah