Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Table View issues
Started by hayful59 Mar 20 2019 08:16 PM

1 reply to this topic
scroll list row tableview lines display newtext table
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

hayful59

[GLOBAL: userInfoPane.html]
hayful59
  • Enthusiast

  • 39 posts
  • Corona SDK

Hello, Im trying to make a large scrollable list using the tableView widget although im very confused on how to add new lines with information to the list, I thought it would be as simply as this, unless im doing something wrong

    local rowTitle = display.newText(row, "Hello", 0, 0, nil, 14)
    local rowTitle2 = display.newText(row, "New Place", 0, 0, nil, 14)
    local rowTitle3 = display.newText(row, "Jackson", 0, 0, nil, 14)
    local rowTitle4 = display.newText(row, "Good Bye ", 0, 0, nil, 14)

Also is there anyway of taking the information from a long table and it automatically convert it to the list?

 

Thanks



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,652 posts
  • Enterprise

Row data is created in the onRowRender() function. Corona's tableView will call that function each time it needs to draw a row. There is a display.newGroup() that's part of each row, which you seem to be using.

 

But before the tableView can render a row, the row has to be inserted into the tableView using the tableView:insertRow() API. Unless you insert the row, you won't have anything to render.

 

This leads to the next set of problems. Generally speaking, the :insertRow() API doesn't pass any data to onRowRender() but you get an index/row number that you can use to look up data in a numerically indexed Lua table. But in practicality, your tableView rows are not always in a 1:1 relationship with a data table's rows of data, In particular if you're hiding/deleting rows from your tableView but you don't want to delete the rows from your data.

 

How to solve this? Well the :insertRow() API can take a table called "params" you can pass a table of data for that specific row and it comes into the onRowRender() function as event.target.params and you can use the data in the params table to fill out your display.newText()'s.

 

Rob




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: scroll, list, row, tableview, lines, display, newtext, table