Confused about TableView widget and sync

I am trying to convert my old ‘tableView.newList’ items over to the new TableView widget and I can’t seem to figure out how to tie to my data table like I previously did the tableView.newList.

I see some people saying you can use list:sync() to tie to your data and update the TableView display but when I try I always get:

attempt to call method ‘sync’ (a nil value)

I have tried using other TableView widget example and I get the same error. I do not see sync() as a method of the TableView in the API.

I am confused. What’s the deal with the TableView widget, table and sync? [import]uid: 70996 topic_id: 35573 reply_id: 335573[/import]

As far as I know there’s no built-in sync method.
You’ll have to roll your own with the current widget API. [import]uid: 70847 topic_id: 35573 reply_id: 141381[/import]

You would have to do the API call to delete all the tableview rows and then reinsert them. The whole data model of the early attempt at tableViews has gone away in favor of the new :insert() method and rowRendering events.

[import]uid: 199310 topic_id: 35573 reply_id: 141429[/import]

Thanks for clearing that up and for your quick reply.

I tried removing just the changed row and then re-adding it but I could not figure out how to add it at the position I want and in between other row. It just always adds to the bottom.

The only way I can figure out if to delete all the rows and re-add them. Not a big deal for me because I have a pretty small list but is there a way to specify the location of the added row?
[import]uid: 70996 topic_id: 35573 reply_id: 141441[/import]

Each row is a display group, holding display objects. You can when creating the row, assign your display objects to be members of the row:

local function onRowRender(event)  
 local row = event.target  
 local rowGroup = event.view  
  
 row.name = display.newText( playerName, 0, 0, storyboard.font, 18)  
 rowGroup:insert(row.name )  

So now the row has a member called name that you can reference like this:

myList.content.rows[i].name

(assuming your list is called myList)

Just change the values and no need to delete the row.

[import]uid: 199310 topic_id: 35573 reply_id: 141446[/import]

Nice solution! Thank you. [import]uid: 70996 topic_id: 35573 reply_id: 141457[/import]

As far as I know there’s no built-in sync method.
You’ll have to roll your own with the current widget API. [import]uid: 70847 topic_id: 35573 reply_id: 141381[/import]

You would have to do the API call to delete all the tableview rows and then reinsert them. The whole data model of the early attempt at tableViews has gone away in favor of the new :insert() method and rowRendering events.

[import]uid: 199310 topic_id: 35573 reply_id: 141429[/import]

Thanks for clearing that up and for your quick reply.

I tried removing just the changed row and then re-adding it but I could not figure out how to add it at the position I want and in between other row. It just always adds to the bottom.

The only way I can figure out if to delete all the rows and re-add them. Not a big deal for me because I have a pretty small list but is there a way to specify the location of the added row?
[import]uid: 70996 topic_id: 35573 reply_id: 141441[/import]

Each row is a display group, holding display objects. You can when creating the row, assign your display objects to be members of the row:

local function onRowRender(event)  
 local row = event.target  
 local rowGroup = event.view  
  
 row.name = display.newText( playerName, 0, 0, storyboard.font, 18)  
 rowGroup:insert(row.name )  

So now the row has a member called name that you can reference like this:

myList.content.rows[i].name

(assuming your list is called myList)

Just change the values and no need to delete the row.

[import]uid: 199310 topic_id: 35573 reply_id: 141446[/import]

Nice solution! Thank you. [import]uid: 70996 topic_id: 35573 reply_id: 141457[/import]