I’m trying to convert my code from the widget 1 to widget 2 library, but I’m having some problems.
I was originally passing some data to the row when called list:insertRow(), but that no longer works, or at least I can no longer access the data. I also cannot access to group to insert.
Previously I did the following:
-- onRender listener for the tableView local function onRowRender( event ) print( "rendered" ) local row = event.target local rowGroup = event.view row.title = row.data.title row.description = row.data.description -- Title local title = txt.new( row.title, 12, 0, native.systemFontBold, 14 ) title:setTextColor( 255, 255, 255 ) title:setReferencePoint( display.CenterLeftReferencePoint ) title.x = 30; title.y = 10 -- must insert everything into event.view: rowGroup:insert( title ) rowGroup:insert( rightArrow ) end -- List local listOptions = { top = 120, height = 380, width = display.contentWidth, maskFile = "images/mask320x390.png", listener = tableViewListener, hideBackground = true, } list = widget.newTableView( listOptions ) --Data fed from a JSON feed into 'data' -- function below is responsible for creating the row list:insertRow{ height=rowHeight, isCategory=isCategory, rowColor=rowColor, lineColor=lineColor, data=data[i], onRowTouch = onRowTouch, onRowRender = onRowRender, }
This worked fine. Then when I updated I needed to move the render and touch events round, but it also meant that event.target and event.view were no longer available in the onRowRender method. How can I now access them in widget2?