I have a tableView object with data read from an Array which I build after reading a remote JSON object. Everything works fine. The problem is that I want to keep a timer hitting that JSON, ensuring that all rows display fresh content. What's the best practice to do that? I have a few options listed here :
(1) Delete the entire TableView and re-create it every time with the new data. (2) Delete all tableRows and enter the new ones back. (3) Change only the data value of the TableView on every refresh
What would you do?
Although everything seems straight foward, I didn't manage to get any of the above working... but instead of trying to get them work, let's focus on the best and recommended way. thanks, George
2 Answers
Accepted Answer
In this case I use setData:
ctrl.getData(function(data){ var rows =[]; for() { rows.push(); } tableView.setData(rows) })
At first I was actually recreating everything using the timer. (this of course is not a nice thing to do since I wasn't removing any elements from my parent window and the whole window could get flooded).
In iPhone I didn't notice anything as it was working fine. In Android though, I saw that the fonts were getting "Bolder and Bolder" , and I was trying to understand what was going on. Finally I noticed that everything was redrawing above themselves ... ! Hence I ended up into this question here.
Yes, my best guess was to update only the datasource too! Tried it and works like a charm!
thanks
Your Answer
Think you can help? Login to answer this question!