Widget 2.0 and row.reRender

I have a “x minutes ago” counter in a tableView and needed to get it updating onscreen, but without reRender working, it never updates (unless I scroll it offscreen and back on of course).

To get it working without reRender I had to do a little tom foolery (half a dozen lines or so, but tom foolery nonetheless). Oh, and kudos for ksan for helping me figure out how to get it done :slight_smile:

First, save off the pointer to the text to later be changed in the row (in onRowRender)

[lua]

    local timestampText = getTS(currMess)   –  get correct timestamp return it as a corona text object

    currentMessages[row.index].TS = timestampText   – Let’s see if we can remove / replace this later… muhahaha

[/lua]

Later, to change it: (in a screenUpdate routine that checks every 30 seconds during an enterFrame event)

[lua]

       – this.messageList is my tableView structure, newTS is my new timestamp text in a row

        this.messageList._view._rows[i]._view:remove(currentMessages[i].TS)   – remove old text

        local newTS = getTS(currentMessages[i])                                               – get new updated text object

        this.messageList._view._rows[i]._view:insert(newTS)                              – insert into row

        currentMessages[i].TS = newTS                                                             – resave pointer for next update

[/lua]

That’s about it. Undocumented, but it works like a champ.

No reRender. No scrollToY, no nothing else.

Edit: ahh shoot, the #@$%@#$$ formatting is messed up, ARGGGGGHHHHH!!!

Bumping this request. Is there a solution for showing a different color background for the selected row??

@staytoooned, yes there is. Keep using widget library 1.0 until version 2.0 is up to par: https://github.com/coronalabs/widget-v1

Hi guys,

Just letting you know a fix for this will be available very soon.

Thanks,

Alex

I came up with a temporary solution that works. Here’s what I did:

tableView:deleteAllRows() data = {} data = nil initData() tableView.\_view.\_rows[index].\_rowColor.default = {6, 140, 253, 200}

What I’m doing is clearing the table, re-initializing it and then highlighting the row. Works fast and gets the job done:)

Bumping this request. Is there a solution for showing a different color background for the selected row??

@staytoooned, yes there is. Keep using widget library 1.0 until version 2.0 is up to par: https://github.com/coronalabs/widget-v1

Hi guys,

Just letting you know a fix for this will be available very soon.

Thanks,

Alex

I came up with a temporary solution that works. Here’s what I did:

tableView:deleteAllRows() data = {} data = nil initData() tableView.\_view.\_rows[index].\_rowColor.default = {6, 140, 253, 200}

What I’m doing is clearing the table, re-initializing it and then highlighting the row. Works fast and gets the job done:)

Deleting all the rows and reinserting them works for me too. Kinda janky though!

Any news on the fix for this ? Its three months since you said “very soon”

Deleting all the rows and reinserting them works for me too. Kinda janky though!

Any news on the fix for this ? Its three months since you said “very soon”