I don’t understand why the params{} data arrive void at onRowRender.
... function scene:create( event ) btnGroup = display.newGroup() tbV = widget.newTableView( { left = 10, top = 300, height = 180, width = 300, onRowRender = onRowRender, noLines = false, hideScrollBar = false, rowHeight =8 } ) btnGroup:insert(tbV) ... local function txtLog( myTxt ) local options = {} options.isCategory = false options.rowHeight = 10 options.rowColor = { default={0.8,0.8,0.8,0.8} } options.lineColor = { 1, 0, 0 } options.params = {message = myTxt} tbV:insertRow{options} end ... local function onRowRender( event ) -- Get reference to the row group local row = event.row local id =row.index local params = event.row.params row.bg = display.newRect( 0, 0, display.contentWidth, 60 ) row.bg.anchorX = 0 row.bg.anchorY = 0 row.bg:setFillColor( 1, 1, 1 ) row:insert( row.bg ) if (event.row.params) then row.nameText = display.newText( params.msg, 6, 0, native.systemFont, 6 ) row.nameText.anchorX = 0 row.nameText.anchorY = 0.5 row.nameText:setFillColor( 0 ) row.nameText.y = 10 row.nameText.x = 0 row:insert( row.nameText ) end return true end
looking with debug:
local params = event.row.params
event.row.params is alway = nil
What I’m making wrong ?
Thanks
Renato
pixec
2
My guess is the params just used when the thing is created, so they dont appear outside newTableView function?
sorry I didn’t put the function in the correct order, this is the correct order.
The onRender function is correctly called, but inside the params are void.
... local function onRowRender( event ) -- Get reference to the row group local row = event.row local id =row.index -- event.row.params is void local params = event.row.params row.bg = display.newRect( 0, 0, display.contentWidth, 60 ) row.bg.anchorX = 0 row.bg.anchorY = 0 row.bg:setFillColor( 1, 1, 1 ) row:insert( row.bg ) if (event.row.params) then row.nameText = display.newText( params.msg, 6, 0, native.systemFont, 6 ) row.nameText.anchorX = 0 row.nameText.anchorY = 0.5 row.nameText:setFillColor( 0 ) row.nameText.y = 10 row.nameText.x = 0 row:insert( row.nameText ) end return true end local function txtLog( myTxt ) local options = {} options.isCategory = false options.rowHeight = 10 options.rowColor = { default={0.8,0.8,0.8,0.8} } options.lineColor = { 1, 0, 0 } options.params = {message = myTxt} tbV:insertRow{options} end function scene:create( event ) btnGroup = display.newGroup() tbV = widget.newTableView( { left = 10, top = 300, height = 180, width = 300, onRowRender = onRowRender, noLines = false, hideScrollBar = false, rowHeight =8 } ) btnGroup:insert(tbV) ...
pixec
4
Ye, but I dont think the params are saved. They are used to create newTableView and then they are lost.
Why they are lost?
I’m just copying an example from Corona University.
You can have a look here:
https://youtu.be/PXo4Rv5KPjo?t=113
and also here:
http://docs.coronalabs.com/api/type/TableViewWidget/insertRow.html
the ‘params’ field.
so how can you send data to fill in the table? with a global variable?
Thanks
Renato