[Resolved] Widget TableView Question

Looking over the sample code for the Widget TableView functionality, I feel like I am missing something. The section that gives an example of adding multiple rows from one render function doesn’t place the next on the different rows, it looks to just stack it up on top of each other. Is there something I am missing?

[code]local widget = require “widget”

_w = display.contentWidth
_h = display.contentHeight

– create the tableView widget
local list = widget.newTableView{
width = _w,
height = _h
}

– create 25 rows using a single onRender listener
for i=1,25 do
local function onRowRender( event )
local group = event.view
local row = event.target
local index = event.index
local id = event.id

local text = display.newText( “Row #” … index … ", id: ", 0, 0, native.systemFont, 14 )
text:setTextColor( 0 )
text:setReferencePoint( display.CenterReferencePoint )
text.x = row.width * 0.50
text.y = row.height * 0.50
end

– insert row into the TableView widget
list:insertRow{
id = “unique-row-” … i,
onRender = onRowRender
}
end[/code]

Any help would be appreciated greatly. [import]uid: 157382 topic_id: 30568 reply_id: 330568[/import]

@se ,

I do not see you inserting everything into the event.view (aka your called group ), have a look below please:

[lua]local widget = require “widget”

_w = display.contentWidth
_h = display.contentHeight

– create the tableView widget
local list = widget.newTableView{
width = _w,
height = _h
}

– create 25 rows using a single onRender listener
for i=1,25 do
local function onRowRender( event )
local group = event.view
local row = event.target
local index = event.index
local id = event.id

local text = display.newText( “Row #” … index … ", id: ", 0, 0, native.systemFont, 14 )
text:setTextColor( 0 )
text:setReferencePoint( display.CenterReferencePoint )
text.x = row.width * 0.50
text.y = row.height * 0.50

– must insert everything into the ‘group’ as you assigned this variable to the event.view:
group:insert( text )
end

– insert row into the TableView widget
list:insertRow{
id = “unique-row-” … i,
onRender = onRowRender
}
end[/lua]

I hope that helps.
Cheers,
Rodrigo.
[import]uid: 89165 topic_id: 30568 reply_id: 122490[/import]

That got it, thanks! [import]uid: 157382 topic_id: 30568 reply_id: 122491[/import]

@se ,

I do not see you inserting everything into the event.view (aka your called group ), have a look below please:

[lua]local widget = require “widget”

_w = display.contentWidth
_h = display.contentHeight

– create the tableView widget
local list = widget.newTableView{
width = _w,
height = _h
}

– create 25 rows using a single onRender listener
for i=1,25 do
local function onRowRender( event )
local group = event.view
local row = event.target
local index = event.index
local id = event.id

local text = display.newText( “Row #” … index … ", id: ", 0, 0, native.systemFont, 14 )
text:setTextColor( 0 )
text:setReferencePoint( display.CenterReferencePoint )
text.x = row.width * 0.50
text.y = row.height * 0.50

– must insert everything into the ‘group’ as you assigned this variable to the event.view:
group:insert( text )
end

– insert row into the TableView widget
list:insertRow{
id = “unique-row-” … i,
onRender = onRowRender
}
end[/lua]

I hope that helps.
Cheers,
Rodrigo.
[import]uid: 89165 topic_id: 30568 reply_id: 122490[/import]

That got it, thanks! [import]uid: 157382 topic_id: 30568 reply_id: 122491[/import]