This is what I am trying to do:
_tableView.data[0].rows[selectedPosY].children[selectedPosX].imageId = tempImageId;
_tableView.data[0].rows[selectedPosY].children[selectedPosX].image = tempImageUrl;
Titanium.API.info("imageIdSelected:" +
_tableView.data[0].rows[selectedPosY].children[selectedPosX].imageId + "imageSelected:" +
_tableView.data[0].rows[selectedPosY].children[selectedPosX].image);
The update is done on the data, but it doesn't reflect in UI table, what is missing?
I even tried doing the below as per How can I refresh my TableView in titanium? & How to resolve Titanium TableView display problem?, but it is not refreshing the UI table _tableView.setData(_tableView.data); win.add(_tableView);
It turns out the only way to update/reload a Titanium.UI.TableView is to get a copy of the updated data (as per ones logic) and reset it in the TableView, using 'setData'. For my example, since the _tableView.data is getting updated (which could be seen through the logging statements), I could copy it using a javascript array copy function like;
Although, with the above knowledge, I had restructure my code, so, I am not using this exact code, but a similar logic. But, overall, this way of updating the table doesn't seem very appealing, if there is any better way of handling this, please post, it would help a lot.
Why are you doing
_tableView.data[0].rows
and then just_tableView.data
when usingsetData
?Your
_tableView.data
should be an array of rows/sections. The Ti.UI.tableView object has the data property but the data should be structured as follows.What does the
.rows
accomplish for you when you are doing it that way, how are you using the.rows
? I'm not positive but I think the_tableView.data
is either no different or is invalid when trying tosetData
.