newTableWidget row how check if exist

Hi,

I have a table widget with images being downloaded using network.request and displayed as they arrive, which works fine.

But, on a slow network and while scrolling fast, sometimes these async callbacks return image info after the row has scrolled past the screen and into oblivion. It then shows error that the row (display group) is missing upon image creation. 

Is there a way to detect if the row still exist before trying to create the row image?

Thank in advance!

Anaqim

I haven’t tested it, but one suggestion is to wrap the image placement/creation within a conditional block that checks the value of the “getRowAtIndex()” API. This API will return nil if the row is not currently in view, so in theory it would simply skip the image rendering if the API returns nil for the index of the row you’re trying to render the image into.

https://docs.coronalabs.com/api/type/TableViewWidget/getRowAtIndex.html

Brent

man, so easy and i never thought of it  :huh:

works like a charm, thanks brent!

if anyone else need a pointer on the subject, this is the conditional statement that works

if object:getRowAtIndex(index) then \<your code\> end

I haven’t tested it, but one suggestion is to wrap the image placement/creation within a conditional block that checks the value of the “getRowAtIndex()” API. This API will return nil if the row is not currently in view, so in theory it would simply skip the image rendering if the API returns nil for the index of the row you’re trying to render the image into.

https://docs.coronalabs.com/api/type/TableViewWidget/getRowAtIndex.html

Brent

man, so easy and i never thought of it  :huh:

works like a charm, thanks brent!

if anyone else need a pointer on the subject, this is the conditional statement that works

if object:getRowAtIndex(index) then \<your code\> end