Putting usernames and scores in TableView

Hello.

I am getting scores from Scoreoid using this code:

local onComplete = function( scores ) for i = 1, #scores, 1 do print( scores[i].username, scores[i].score ) end end scoreoid:getScores( orderBy, order, limit, startDate, endDate, platform, difficulty, onComplete )  

Instead of this print( scores[i].username, scores[i].score ), I wanna show each scores[i].username and scores[i].score in a table view widget.

Here is a link to table view widget example: http://docs.coronalabs.com/api/library/widget/newTableView.html

How to implement this for loop with table view widget? I can’t make it work. 

So I need to edit the example of Table View widget to show each username and score in each row.

Help please :slight_smile:

You have to have your tableView created and scoped so you can access it inside your onComplete handler’s for loop.

You need a function to render the tableView row.  This is typically called “onRowRender” and is defined as part of the tableView’s init code.

local function onRowRender(event)

end

If your tableView rows are going to be in a one to one relationship with your scores table (i.e. you are not going to have category rows, or other header, informational rows), then you can use the tableView’s row index value to index into your score array.  The onRowRender function will contain all the display.newText()'s you need to create each row.

You have to have your tableView created and scoped so you can access it inside your onComplete handler’s for loop.

You need a function to render the tableView row.  This is typically called “onRowRender” and is defined as part of the tableView’s init code.

local function onRowRender(event)

end

If your tableView rows are going to be in a one to one relationship with your scores table (i.e. you are not going to have category rows, or other header, informational rows), then you can use the tableView’s row index value to index into your score array.  The onRowRender function will contain all the display.newText()'s you need to create each row.