TableView using SQLite Database

You’re most welcome. Look forward to hearing your good news! 

Unfortunately I can’t figure out how to setup the counter for fixing the out of sync data :frowning:

So that means you did get your categories to show & stick now. All ok with that? If so post another set of code so I can see where you are. I will see if I can give you some more help for that last issue. 

I just ran into errors… First row renders with Category name then no other rows render at all. Code is below:

local isPersonType = 0

    local function onRowRender( event )
        local phase = event.phase
        local row = event.row

        if row.isCategory == true then
            if thisPersonType == 1 then
                rowTitle = display.newText( row, “Visitors”, 0, 0, nil, 16 )
            elseif thisPersonType == 2 then
                rowTitle = display.newText( row, “Personnel”, 0, 0, nil, 16 )
            end --if
            rowTitle.x = display.contentCenterX
            rowTitle.y = row.contentHeight * 0.5
        else
            rowTitle = display.newText( row, evacRecs[row.index].givenname…" "…evacRecs[row.index].familyname, 0, 0, nil, 16 )
            rowTitle.x = row.x - ( row.contentWidth * 0.5 ) + ( rowTitle.contentWidth * 0.5 ) + 20
            rowTitle.y = row.contentHeight * 0.25
        end --if
        rowTitle:setTextColor( 0, 0, 0 )
        print("rowtitle.x = " …rowTitle.x)
        if evacRecs[row.index].cd ~= nil then
            rowCD = display.newText( row, evacRecs[row.index].cd, 0, 0, nil, 12 )
            rowCD.x = row.x - ( row.contentWidth * 0.5 ) + ( rowCD.contentWidth * 0.5 ) + 20
            rowCD.y = rowTitle.y + 15
            rowCD:setTextColor( 0, 0, 0 )
            print("rowCD.x = " …rowCD.x)
        end --if
        if evacRecs[row.index].mobileno ~= nil then
            rowMobile = display.newText( row, evacRecs[row.index].mobileno, 0, 0,  nil, 12 )
            rowMobile.x = row.x - ( row.contentWidth * 0.5 ) + ( rowMobile.contentWidth * 0.5 ) + 20
            rowMobile.y = rowTitle.y + 30
            rowMobile:setTextColor( 0, 0, 0 )
            print("rowmobile.x = " …rowMobile.x)
        end --if
    end – function

    function loadSQLList()
        
        evacdb = sqlite3.open( evacpath )
            
        local function onSystemEvent( event )
            if event.type == “applicationExit” then
                evacdb:close()
            end – if
        end – function

        for b in evacdb:nrows(“SELECT * FROM Visitor ORDER BY PersonType, Status, GivenName, FamilyName”) do
            idx = idx + 1
            evacRecs[idx] = {}
            evacRecs[idx].sysID = b.SysID
            evacRecs[idx].givenname = b.GivenName
            evacRecs[idx].familyname = b.FamilyName
            evacRecs[idx].cd = b.CD
            evacRecs[idx].mobileno = b.MobileNo
            evacRecs[idx].host = b.Host
            evacRecs[idx].status = b.Status
            evacRecs[idx].persontype = b.PersonType
            

            local rowHeight = 75
            local rowColor =
            {
                default = { 255, 255, 255 },
                over = { 0, 174, 239 },
            }
            local lineColor = { 220, 220, 220 }
            local rowCategoryHeight = 50
            local rowCategoryColor =
            {
                default = { 212, 212, 212, 200},
            }
                
            if thisPersonType ~= evacRecs[idx].persontype then
                thisPersonType = evacRecs[idx].persontype – this would cause an error if set to: thisPersonType ~= evacRecs[idx].persontype
                evacTableView:insertRow
                {
                    isCategory = true,
                    rowHeight = rowCategoryHeight,
                    rowColor = rowCategoryColor,
                    lineColor = lineColor,
                }
                evacTableView:insertRow
                {
                    isCategory = false,
                    rowHeight = rowHeight,
                    rowColor = rowColor,
                    lineColor = lineColor,
                }
            else
                evacTableView:insertRow
                {
                    isCategory = false,
                    rowHeight = rowHeight,
                    rowColor = rowColor,
                    lineColor = lineColor,
                }
            end --if

        end – for
        
        evacdb:close()
        
    end – function

Ok. Will get back to you later tonight unless someone else beats me to it. Running out the door right now I’m afraid.

No worries!

For anyone watching this… ksan found that the line: ‘transition.to( group, {time = 1000, x = 0, onComplete = testSQL})’ was causing the Categories not sticking issue. Bug report posted. A big thank you to ksan for helping out with this.

Regards,

Trent

It was great fun tracking this one down. Making a cutdown version of your project so we can submit the bug report. 

Bug # 25367 - transition.to causes tableView Category sticky at the top behavior to malfunction - logged. Thanks much discovering this one.