自从我将应用更新到最新的sdk版本后,我的TableViewSection
似乎不再使用新行进行更新。
以下是我的观点:
<Alloy>
<Tab id="customers" title="Customers" icon="glyphicons/glyphicons/png/glyphicons_003_user.png">
<Window id="customers_window" title="Customers">
<RightNavButton>
<Button id="add">Add</Button>
</RightNavButton>
<TableView id="table" filterAttribute="title">
<SearchBar platform="android,ios"/>
<TableViewSection id="customers_list"></TableViewSection>
</TableView>
</Window>
</Tab>
</Alloy>
这是我的控制器:
...
function customersCallback (customers, callback) {
// throw those into globals so we can use them again
Alloy.Globals.customers = customers;
// empty list first
$.customers_list.rows = [];
customers.forEach(function(customer) {
Ti.API.info(customer);
var payload = {
customer : customer
};
var row=Alloy.createController('customer_row',payload).getView();
$.customers_list.add(row);
});
// tell async we're finished
callback(null);
};
...
我在某处读到,您现在可以使用appendRow
来呈现TableViewSection
。但是,当我尝试使用它时,我得到了:
'undefined'不是一个函数(评估 customers.js上的'$ .customers_list.appendRow(row)')(第11行)
无论如何我可以强制更新吗?或者访问appendRow
?
Titanium SDK 3.2.0 GA
部署到iOS模拟器v7
答案 0 :(得分:1)
查看文档,您的customer_list是一个TableViewSection,而appendRow似乎不是一个函数。对于TableViewSection,您使用函数'add'具有以下注释:
在此部分添加表格视图行。
在将部分添加到表之前应该调用。打电话加 已添加到表中的部分不会更新 表
要在将某个行添加到表中后向其中添加行,请调用一行 TableView方法,insertRowBefore,insertRowAfter或 appendRow。
在Android上,可以通过添加或删除来更新部分 行然后重置表视图的数据属性。但是,这个 方法不可移植,不推荐使用。
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.TableViewSection-method-add
我没有找到任何具体的例子,如果没有使用他们在文档中避免使用的方法, How to append a row to a TableViewSection in Titanium?