TableView items disapper

Dears,

Have anybody seen this strange effect: tableview items disappear when list scroling up ?

It seems that onRowRender works correctly - I inserted print and you could see the result in the console.

Please look at my screenshots:

  1. Application started -

  2. Scrolling down - 

3) Scrolling up - 

4) Scrolling up - 

5) Scrolling up - 

Corona simulator version: 2014.2189 (2014.3.6)

How to fix it ?

Regards, 

Oleg

We would need to see your onRowRender code.  However, there have been quite a few bugs in widgets fixed since 2189 in daily builds.   We are working on a new public build so these fixes should be available to you soon.  If you want to post your onRowRender function here, make sure to include it in and tags (leave out the spaces)

Rob

Dear Rob!

I am sorry for my late reply … I have to spend all my free time on my main job.

This problem is still exists so please … would you be so kind and look at my onRowRender

[lua]

    local function onRowRender( event )

        --Set up the localized variables to be passed via the event table

        local row = event.row

        local id = row.index

        local params = event.row.params

        

        print("rendering row id = " … id)

        local rowHeight = row.height

        local rowWidth = display.contentWidth

        row.bg = display.newRect( 0, 0, rowWidth, rowHeight )

        row.bg.anchorX = 0

        row.bg.anchorY = 0

        row.bg:setFillColor(myConsts.RGB2(“BACKGROUND”))

        row:insert(row.bg)

        if ( event.row.params ) then    

            row.avatar = display.newImageRect(“testdata/” … id … “.png”, system.ResourceDirectory, rowHeight, rowHeight )

            row.avatar.x = rowHeight / 2

            row.avatar.y = rowHeight / 2

            row:insert(row.avatar)

            local  fromtext = "              " … id

            row.nameText = display.newText({text = fromtext, x = rowHeight, y = rowHeight / 30, 

                                            fontSize = myConsts.GET(“TEXT2_H”), font = myConsts.GET(“MAINFONT”)})

            row.nameText.anchorX = 0

            row.nameText.anchorY = 0

            row.nameText:setFillColor(myConsts.RGB2(“TEXT2”))

            row:insert( row.nameText )

        end

        row.bottomline = display.newRect( 0, rowHeight - 2, rowWidth, rowHeight )

        row.bottomline.anchorX = 0

        row.bottomline.anchorY = 0

        row.bottomline:setFillColor(myConsts.RGB2(“ITEMDELIMCOLOR”))

        row:insert(row.bottomline)

        return true

    end   

[/lua] 

I guess I’m also going to need to see your insertRows() call too.  It appears that when you scroll back event.row.params isn’t set for the rows it’s trying to draw.  Not sure why that’s happening, but that would explain the behavior.

Rob

I created renderList() and call it on scene show event (phase “will”)

[lua]

function scene:renderList()

    local sceneGroup = self.view

    

    – Draw list caption and points

    scene:renderListCaption()

    

    local tabBarHeight = 0

    myList = widget.newTableView {

       top = navBarHeight, 

       width = display.contentWidth, 

       noLines = true,

       height = display.contentHeight - navBarHeight - tabBarHeight,

       onRowRender = onRowRender,

       onRowTouch = onRowTouch,

       listener = scrollListener

    }    

    for i = 1, #myData do

       myList:insertRow{

          rowHeight = scene:calcRowHeigth(myData[i]),

          isCategory = false,

          rowColor = myConsts.RGB3(“BACKGROUND”),

          params = {

             name = myData[i].name,

             phone = myData[i].phone,

             place = myData[i].place,

             msg = myData[i].msg

          }

       }

    end

    sceneGroup:insert(myList)

end

[/lua]

Are you still using build 2189 or have you upgraded to 2393 (or 2393a for Macs)?

Rob

Dear Rob,

Few minutes ago tried 2393 and got the same result :frowning:

May be I should attach or send whole project ?

Oleg

Dear Rob,

I’ve found the “reason” - this code in “onRowRender” leads to this strange effect. Do u know whats wrong in this part?

[lua]

        row.bottomline = display.newRect( 0, rowHeight - 2, rowWidth, rowHeight )

        row.bottomline.anchorX = 0

        row.bottomline.anchorY = 0

        row.bottomline:setFillColor(myConsts.RGB2(“ITEMDELIMCOLOR”))

        row:insert(row.bottomline)

[/lua]

I only tried to make item delimeter more readable.

I think the problem is that your rectangle isn’t two pixels high, but it’s rowHeight pixels high and positioned 2 pixels above the rowHeight.

The display.newRect()'s parameters are:   X, Y, width, height     not:  X, Y, xOffset, yOffset

as you seem to be doing it here.

Rob

Dear Rob, thank you! I’ve fixed it and now it works fine! 

We would need to see your onRowRender code.  However, there have been quite a few bugs in widgets fixed since 2189 in daily builds.   We are working on a new public build so these fixes should be available to you soon.  If you want to post your onRowRender function here, make sure to include it in and tags (leave out the spaces)

Rob

Dear Rob!

I am sorry for my late reply … I have to spend all my free time on my main job.

This problem is still exists so please … would you be so kind and look at my onRowRender

[lua]

    local function onRowRender( event )

        --Set up the localized variables to be passed via the event table

        local row = event.row

        local id = row.index

        local params = event.row.params

        

        print("rendering row id = " … id)

        local rowHeight = row.height

        local rowWidth = display.contentWidth

        row.bg = display.newRect( 0, 0, rowWidth, rowHeight )

        row.bg.anchorX = 0

        row.bg.anchorY = 0

        row.bg:setFillColor(myConsts.RGB2(“BACKGROUND”))

        row:insert(row.bg)

        if ( event.row.params ) then    

            row.avatar = display.newImageRect(“testdata/” … id … “.png”, system.ResourceDirectory, rowHeight, rowHeight )

            row.avatar.x = rowHeight / 2

            row.avatar.y = rowHeight / 2

            row:insert(row.avatar)

            local  fromtext = "              " … id

            row.nameText = display.newText({text = fromtext, x = rowHeight, y = rowHeight / 30, 

                                            fontSize = myConsts.GET(“TEXT2_H”), font = myConsts.GET(“MAINFONT”)})

            row.nameText.anchorX = 0

            row.nameText.anchorY = 0

            row.nameText:setFillColor(myConsts.RGB2(“TEXT2”))

            row:insert( row.nameText )

        end

        row.bottomline = display.newRect( 0, rowHeight - 2, rowWidth, rowHeight )

        row.bottomline.anchorX = 0

        row.bottomline.anchorY = 0

        row.bottomline:setFillColor(myConsts.RGB2(“ITEMDELIMCOLOR”))

        row:insert(row.bottomline)

        return true

    end   

[/lua] 

I guess I’m also going to need to see your insertRows() call too.  It appears that when you scroll back event.row.params isn’t set for the rows it’s trying to draw.  Not sure why that’s happening, but that would explain the behavior.

Rob

I created renderList() and call it on scene show event (phase “will”)

[lua]

function scene:renderList()

    local sceneGroup = self.view

    

    – Draw list caption and points

    scene:renderListCaption()

    

    local tabBarHeight = 0

    myList = widget.newTableView {

       top = navBarHeight, 

       width = display.contentWidth, 

       noLines = true,

       height = display.contentHeight - navBarHeight - tabBarHeight,

       onRowRender = onRowRender,

       onRowTouch = onRowTouch,

       listener = scrollListener

    }    

    for i = 1, #myData do

       myList:insertRow{

          rowHeight = scene:calcRowHeigth(myData[i]),

          isCategory = false,

          rowColor = myConsts.RGB3(“BACKGROUND”),

          params = {

             name = myData[i].name,

             phone = myData[i].phone,

             place = myData[i].place,

             msg = myData[i].msg

          }

       }

    end

    sceneGroup:insert(myList)

end

[/lua]

Are you still using build 2189 or have you upgraded to 2393 (or 2393a for Macs)?

Rob

Dear Rob,

Few minutes ago tried 2393 and got the same result :frowning:

May be I should attach or send whole project ?

Oleg

Dear Rob,

I’ve found the “reason” - this code in “onRowRender” leads to this strange effect. Do u know whats wrong in this part?

[lua]

        row.bottomline = display.newRect( 0, rowHeight - 2, rowWidth, rowHeight )

        row.bottomline.anchorX = 0

        row.bottomline.anchorY = 0

        row.bottomline:setFillColor(myConsts.RGB2(“ITEMDELIMCOLOR”))

        row:insert(row.bottomline)

[/lua]

I only tried to make item delimeter more readable.

I think the problem is that your rectangle isn’t two pixels high, but it’s rowHeight pixels high and positioned 2 pixels above the rowHeight.

The display.newRect()'s parameters are:   X, Y, width, height     not:  X, Y, xOffset, yOffset

as you seem to be doing it here.

Rob

Dear Rob, thank you! I’ve fixed it and now it works fine!