TableView row content disappearing when scrolling - Intermittent

Hi All!

Completely new to the forum and fairly new to Corona. (I’ve been using it now for about 2 weeks so I apologize in advance for any stupid questions. But here comes one now… :slight_smile: )

I have an app setup using Composer for the scenes and a tableView in 2 of them. The data source for the table view is a web api (my own) that simply returns an array of json objects with a network.request and then consumes it with a standard listener.

The data returned from the web api is not huge. (My issue is occuring with either 10 rows or 100+ rows).

When first running the app and scroll down (revealing the text below), everything works perfectly. But when I scroll back up (revealing text from the top), most of the rows have blank data. The row spacing is still there, as is the backgroud color I set for the “name” row but the text is missing. (Some of the Name row text is preserved but most isn’t.)

(*I can just see the text start to draw at the top of the scene as I scroll but it’s just a couple of pixels before it disappears.)

There are no errors anywhere and the console shows me the rows are being rendered with the correct data.

Here’s the code:

I populate the tableView from within the network listener .

local function networkListener( event ) local myData = {}     if ( event.isError ) then         print( "Network error!" )     else         myNewData = event.response         print ("From server: "..myNewData)         local myData = (json.decode( myNewData))         --table.sort (myData)         for key,value in orderedPairs(myData) do             local h = 30             print ("Looping1: "..value.RESULT)             if (value.TRACK == "") then                 value.DATE = ""                 h = 30             end             myList:insertRow{                 rowHeight = h,                 isCategory = false,                 rowColor = { 1, 1, 1 },                 lineColor = { 1, 1, 1 },                 params = {                     name = value.TRACK,                     date = value.DATE,                     class = value.CLASS,                     results = value.CLASS.." :: "..value.RESULT                 }             }         end     end end

Here’s the tableView setup;

local navBarHeight = 60 local tabBarHeight = 50 local myList = widget.newTableView {    top = navBarHeight,    width = display.contentWidth,    height = display.contentHeight,    onRowRender = onRowRender,    onRowTouch = onRowTouch,    listener = scrollListener }

… and here’s the row renderer. (I wrap all the rows with If’s so that they don’t get created if there’s no data for a particular field).

  local function onRowRender( event )    local row = event.row    local id = row.index    local params = event.row.params    --print ("Setting: "..params.results)    row.bg = display.newRect( 0, 0, display.contentWidth, 60 )    row.bg.anchorX = 0    row.bg.anchorY = 0    row.bg:setFillColor( 1, 1, 1 )    row.bg:setFillColor( 0, 0, 0 )    if (params.name ~= "") then        row.bg:setFillColor( .1, .1, .1 )    end    row:insert( row.bg )   if ( event.row.params ) then         if (params.name ~= "") then       row.nameText = display.newText( params.name, 12, 0, native.systemFontBold, 16 )       row.nameText.anchorX = 0       row.nameText.anchorY = 0.5       row.nameText:setFillColor( 0, 1, 0 )       row.nameText.y = 13       row.nameText.x = 10     end     if (params.results ~= "") then       row.resultsText = display.newText( params.results, 12, 0, native.systemFont, 14 )       row.resultsText.anchorX = 0       row.resultsText.anchorY = 0.5       row.resultsText:setFillColor( 1 )       row.resultsText.y = 13       row.resultsText.x = 10       if (params.name == "") then            row.resultsText.y = 13       end     end     if (params.date ~= "") then       row.dateText = display.newText( params.date, 12, 0, native.systemFontBold, 14 )       row.dateText.anchorX = 0       row.dateText.anchorY = 0.5       row.dateText:setFillColor( 0, 4, 0 )       row.dateText.x = display.contentWidth - 75       row.dateText.y = 13     end       if (params.name ~= "") then         row:insert( row.nameText )         row:insert( row.dateText )       end       if (params.name == "") then         row:insert( row.resultsText )         --print ("Setting: "..params.results)       end    end    return true end

Scene creation… (all the other scene functions are the default ones from the Composer template without any code changes).

function scene:create( event )     local sceneGroup = self.view     -- Initialize the scene here.     sceneGroup:insert( myList )     network.request( "MY\_URL", "GET", networkListener )          end

Any help would be appreciated.

Thanks!

I finally figured it out.

It was the first row insert in onRender (the row background). Removing that fixed the disapearing content issue but trashed the menu above it. Soo… I gave that approach up. However, by simply setting the row color to transparent, it resolved everything. (Setting rowColor to my desired bg color in :insertRow method now).

(I don’t know how to mark this solved myself while not marking it as “Best answered” as well. So I’ll leave it open for now).

row.bg = display.newRect( 0, 0, display.contentWidth, 60 )    row.bg.anchorX = 0    row.bg.anchorY = 0    row.bg:setFillColor( 0, 0, 0, 0 ) -- transparent    row:insert( row.bg )

I finally figured it out.

It was the first row insert in onRender (the row background). Removing that fixed the disapearing content issue but trashed the menu above it. Soo… I gave that approach up. However, by simply setting the row color to transparent, it resolved everything. (Setting rowColor to my desired bg color in :insertRow method now).

(I don’t know how to mark this solved myself while not marking it as “Best answered” as well. So I’ll leave it open for now).

row.bg = display.newRect( 0, 0, display.contentWidth, 60 )    row.bg.anchorX = 0    row.bg.anchorY = 0    row.bg:setFillColor( 0, 0, 0, 0 ) -- transparent    row:insert( row.bg )