Hello guys !
So here is the thing, i had a big issue with the table view widget because i needed to know in real time in my code when a new row was being added to the table.
That sounds easy to do using the provided rows counting method, but there was one case that didn’t work for me:
When rows are being deleted / added because they are rendered out of the table view screen, for example, if the table view can show 6 rows and you have 10 of them, using the scrollbar to go up / down will make them deleted / added again.
I struggled a bit but here is the hack i did:
DISCLAIMER: We are using the internal private methods, so this workaround will probably not cope well with updates and you might have to update your code when upgrading your corona’s version.
local oDisplayObject = oWidget.newTableView { left = 50, top = 50, topPadding = 1, bottomPadding = 1, width = 300, height = 300, maskFile = 'yourmaskfile', hideBackground=false, onRowRender = fctOnRowRender, hideScrollBar=false, isLocked=false, } -- We add 2 asserts so that if an update breaks our system we will be notified straight away assert (oDisplayObject.\_view ~= nil, 'tableView \_view must exist') assert (oDisplayObject.\_view.\_createRow ~= nil, 'tableView \_createRow must exist') -- We override the default internal create row method so that we are notified of rows additions local fctCreateRow = oDisplayObject.\_view.\_createRow local clsCreateRow = function (...) local aArray = {...} local oRow = aArray[2] local nIndex = oRow.index print ('A new row with index:'..nIndex..' has been created !') return fctCreateRow(...) end oDisplayObject.\_view.\_createRow = clsCreateRow
And voila
Feel free to replace the content of the clsCreateRow closure function by anything you need doing, for example, incrementing your internal rows count
Enjoy !
Teddy