Issue with a newTableView not populating (using sqlite3 database tutorial)

Okay, I think I’ve found the culprit. That being said, I don’t know how to fix it.

I wasn’t passing the parameters to the onRowRender Function because of it’s placement in the code. I moved it and tested it with print statements and I’m getting all my variables populating inside the onRowRender Function. However, no dice on getting the Table to populate. So doing some further digging I found an issue with the  display.newText function which reads:

Gotchas

The newText() object uses a mask when the object is created. Since there is a  nested  mask limit of three on all platforms, care must be taken when inserting text into acontainerScrollView, or TableView (these also consume a mask unit). If you exceed the mask nesting limit, the text may appear as a solid white block.

ScreenShot2014-05-15at104045PM.png

As far as I can tell I’m just getting white blocks like the GOTCHAS section describes.

But I have no idea how to fix the issue with the little documentation provided. I have tried only populating the id, removing all un required fields, etc. But no luck.

Here is my code for anyone who thinks they have an answer. Thanks in advance.

[lua]–TABLE VIEW OF DATABASE

    -------------------------------------------------------

    – HANDLE TABLEVIEW ROW RENDERING

    -------------------------------------------------------

    local function onRowRender ( event )

        

        local row = event.row

        

            print(row.params.id)

            print(row.params.capture)

            print(row.params.timeDate)

        – common row elements

        local font = native.systemFont

        local fontSize = 24

        local rowHeight = row.height / 2

        

        – display.newText options

        local options_id = {

            parent = row,

            text = row.params.id,

            x = 50,

            y = rowHeight,

            font = font,

            fontSize = fontSize,

        }

        

        – add row object

        row.id = display.newText ( options_id )

        row.id.anchorX = 0

        --row.id:SetFillColor( 1, 0, 0 )

        

        – display.newText options

        local options_capture = {

            parent = row,

            text = row.params.capture,

            x = 100,

            y = rowHeight,

            font = font,

            fontSize = fontSize,

        }

        

        – add row object

        row.capture = display.newText ( options_capture )

        row.capture.anchorX = 0

        --row.capture:SetFillColor( 1, 0, 0 )

        

        – display.newText options

        local options_timeDate ={

            parent = row,

            text = row.params.timeDate,

            x = 200,

            y = rowHeight,

            font = font,

            fontSize = fontSize,

        }

        

        – add row object

        row.timeDate = display.newText ( options_capture )

        row.timeDate.anchorX = 0

        --row.timeDate:SetFillColor( 1, 0, 0 )

        

        

    end

    -------------------------------------------------------

    – 

    –  CREATE TABLEVIEW WIDGET

    –

    -------------------------------------------------------

    

    local table_options = {

        

        top = _H * 0.5,

        left = _W * 0.05, – 1/2 of the remainder of the Window

        width = _W * 0.9, – 90% of the window width

        height = _H * 0.4,

        listener = tableViewListener,

        backgroundColor = { 0.95, 0.95, 0.95 },

        onRowRender = onRowRender,

        

    }

    

    local tableView = widget.newTableView( table_options ) 

    

    

    -------------------------------------------------------

    – 

    – RETREIVE DATABASE DATA

    – 

    --------------------------------------------------------- 

    for row in db:nrows(“SELECT * FROM input”) do

        

    ------------------------------------------------        

    –     TESTING READING OF DATABASE ELEMENTS

–            print(row.id)

–            print(row.capture)

–            print(row.timeDate)

    ------------------------------------------------ 

        

        --Parameter lua table

        local rowParams = {

            id = row.id,

            capture = row.capture,

            timeDate = row.timeDate

        }

        

        --Add tableView rows

        tableView:insertRow(

        {

            rowHeight = 50,

            params = rowParams,

        }

        )

    end[/lua]

Try explicitly inserting the display elements into the row view, like this: temp = display.newText(…) row:insert(temp) for each of your display objects in the row. Make sure you set the fill color as well. I’m using the latest public build:Starter v2014.2189 I also use Sqlite, and do queries, inserts, updates, and deletes into a tableview. It all seems to work well, except that there is a bug in the current public build mentioned above. Upon deleting a middle row in the tableview, you will notice display rows overlapping, and see missing horizontal lines. They have fixed this in a daily build, but those of us on the starter license won’t see this fixed until the next public build, hopefully soon! Good luck!

Awesome I will try that. Thanks for the reply

Bvsmailuser. Thanks for the recommendation. Got it working with about half the code that the Corona University Video shows.

Here is the final code to get it to work. At least show up on the table. I have a lot to add to it to get it to do exactly what I want, but now at least I can move forward.

[lua]


– SQL TABLE – HANDLE TABLEVIEW RENDERING  

---------------------------------------------------------------------------------   

    

    local function onRowRender ( event )

        

        local row = event.row

            

            local rowId = display.newText(row, row.params.id, 50, row.height / 2, system.nativeFont , 24)

            local rowCapture = display.newText(row, row.params.capture, 150, row.height / 2, system.nativeFont , 24)

            local rowtimeDate = display.newText(row, row.params.timeDate, 1350, row.height / 2, system.nativeFont , 24)

            rowId.anchorX = 0

            rowCapture.anchorX = 0

            rowtimeDate.anchorX = 1.0

            rowId:setTextColor(0,0,0)

            rowCapture:setTextColor(0,0,0)

            rowtimeDate:setTextColor(0,0,0)

    end

    

    


– SQL TABLE – CREATE TABLEVIEW WIDGET


    local table_options = {

        

        top = _H * 0.1,

        height = _H * 0.8,

        backgroundColor = { 1, 1, 1 },

        onRowRender = onRowRender,

    }

    

    local tableView = widget.newTableView( table_options)

    


– SQL TABLE – RETRIEVE DATA FROM DATABASE


    for row in db:nrows(“SELECT * FROM input”) do

        

—      TESTING READING OF DATABASE ELEMENTS

–        print(row.id)

–        print(row.capture)

–        print(row.timeDate)

------------------------------------------------ 

        --parameters for lua table

        local rowParams = {

            id = row.id,

            capture = row.capture,

            timeDate = row.timeDate,

        }

        

        – add tableview row

        tableView:insertRow(

            {

            rowHeight   = 50,

            params      = rowParams,

            }

        )

    end[/lua]

Corona437,

Glad you got it working!

Good luck,

BVS