简体   繁体   English

钛 - 重新加载表格视图数据?

[英]Titanium - reload tableview data?

So I have a Titanium.UI.tableview in my main window in my tab group which displays a list of questions.所以我在我的选项卡组中的主要 window 中有一个 Titanium.UI.tableview,它显示了一个问题列表。

In another tab I have an "add a question" form.在另一个选项卡中,我有一个“添加问题”表单。 When this is filled out and submitted if it all goes through I need to be able to update the data in the table view in the first window.填写并提交后,如果一切顺利,我需要能够更新第一个 window 中表视图中的数据。

How would I do this?我该怎么做? I don't mind where it happens... I was trying to find a way of refreshing the tableview data when you click onto that tab, but if there's some way of "remotely" updating the table view (from the add a question view) that would be the best way really (so it doesn't have to update EVERY time you click that tab).我不介意它发生在哪里...当您单击该选项卡时,我试图找到一种刷新表格视图数据的方法,但是如果有某种“远程”更新表格视图的方式(从添加问题视图) 这确实是最好的方法(因此不必每次单击该选项卡时都更新)。

Thank you.谢谢你。

I'm not sure about this, but maybe you can try to store your questions as a list property for the app??我不确定这一点,但也许您可以尝试将您的问题存储为应用程序的列表属性?

Ti.App.Properties.setList('Questions',YOURLIST);

Then when you're filling out the TableView rows just call each question in a loop然后,当您填写 TableView 行时,只需循环调用每个问题

for(var i = 0 ;i< Ti.App.Properties.getList('Questions').length;i++)
{ use Questions[i] to fill up row }
....add to TableView

That way, whenever you need to add a new question to the list, just call it and push your new question into the list.这样,每当您需要向列表中添加新问题时,只需调用它并将您的新问题推送到列表中即可。

var tempList = Ti.App.Properties.getList('Questions');
tempList.push(NEWQUESTION);
Ti.App.Properties.setList('Questions',tempList);
[tableView reloadData] ;

this method will refresh your UITableView with changed DataSource.You can add this in you viewWillAppear method此方法将使用更改的 DataSource 刷新您的 UITableView。您可以在 viewWillAppear 方法中添加它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM