I really need some help placing a running score into the TableView. All I need it to do is take the number from a server (already done), and then start incrementing or decrementing by 1 every second. It is not updating the server each increment/decrement, but it should look like it is by the numbers changing.
I have tried the timer.performWithDelay, but it works only once when it’s placed right after showing the initial example score, so I’m assuming I need to do this somewhere outside onRowRender().
I do not just want to call tableView:reloadData() as it updates all the other Data in the row and looks sloppy which is not needed. I’ve set up a simple example and I have the most important section in different font.
local widget = require( “widget” )
local function onRowRender( event )
local row = event.row
local rowHeight = row.contentHeight
local rowWidth = row.contentWidth
local rowTitle = display.newText( row, "Row " … row.index, 0, 0, nil, 14 )
rowTitle:setFillColor( 0 )
rowTitle.anchorX = 0
rowTitle.x = 0
rowTitle.y = rowHeight * 0.5
…
… ------- Nested code to get the data needed from server
…
…local scoreNeedsUpdating = dataPulledFromServerForEachUser
…local exampleScore
…exampleScore = display.newText(row, scoreNeedsUpdating ,0,0,“Arial”,12)
…exampleScore.x = myData._W*0.8
…exampleScore.y = sceneGroupContentHeight * 0.50
…exampleScore.anchorX = 0
…exampleScore:setFillColor( 0, 0, 0 )
…
…
…
end
local tableView = widget.newTableView
{
left = 200,
top = 200,
height = 330,
width = 300,
onRowRender = onRowRender,
}
for i = 1, #usersPulledFromServer do
tableView:insertRow{}
end