下面是一個簡單的(經典的鈦)應用程序,通過一些按鈕顯示清除並重新填充表的data
屬性。我會仔細檢查你的TagsData部分/行的有效性,以確保數組中的所有內容都被正確設置。
var
win = Ti.UI.createWindow({
title: "Table Funs",
layout: "vertical",
backgroundColor: "#ffffff"
}),
navwin = Ti.UI.iOS.createNavigationWindow({
window: win
}),
table = Ti.UI.createTableView(),
clearButton = Ti.UI.createButton({
title: "Clear Table",
width: Ti.UI.FILL,
height: 44,
backgroundColor: "#f4f4f4",
color: "red",
bottom: 1
}),
fillButton = Ti.UI.createButton({
title: "Fill Table",
width: Ti.UI.FILL,
height: 44,
backgroundColor: "#f4f4f4",
color: "blue",
bottom: 1
}),
tableData = [];
// Fill up tableData array with rows
tableData.push(Ti.UI.createTableViewRow({ title: "Hey" }));
tableData.push(Ti.UI.createTableViewRow({ title: "this" }));
tableData.push(Ti.UI.createTableViewRow({ title: "is" }));
tableData.push(Ti.UI.createTableViewRow({ title: "a" }));
tableData.push(Ti.UI.createTableViewRow({ title: "table" }));
clearButton.addEventListener("click", function() {
Ti.API.debug("Clicked clear button.");
table.setData(null);
return;
});
fillButton.addEventListener("click", function() {
Ti.API.debug("Clicked fill button.");
table.setData(tableData);
return;
});
// Fill table with our data
table.setData(tableData);
// Build window
win.add(clearButton);
win.add(fillButton);
win.add(table);
navwin.open();
來源
2014-10-08 06:03:55
Kip
我可以看看你如何更新'TagsData'中的數據嗎?你必須在添加最新數據之前清除它'TagsData = []'... – Coyote 2014-10-06 08:08:57