titanium studio adding rows to section
I cannot see what I am doing wrong here. Simply put, I want to add custom row to a section, add the sectio开发者_StackOverflow中文版n to a table view, then display the view in my window. Sounds easy enough. I've stepped through my code so many times that I can no longer see what I'm missing (I think we've all been there). So I need a fresh set of eyes to look at it.
First, I know I get data into the row. I add the row to the section via a for loop in the success callback from the server. I get no errors. The section appears in the window. But I simply cannot get the rows to display.
To avoid dumping the code in this block, you can find it pasted here.
If you need more information, please feel free to ask.
Thanks.
Wow, This was a tough nut to crack. One of my more-informed colleagues solved it over the weekend. Rather than pushing and adding elements to the parent. He simply used the appendRow method to add a row to an empty array which then was added to the table view.
Create the table view first:
// CREATE RESULTS TABLEVIEW
var tvResults = Ti.UI.createTableView({
backgroundColor : "white",
data : [],
top : 55,
left : 10,
width : 260,
height : 250,
borderColor : appHeaderColor,
borderWidth : 1,
borderRadius : 10
});
viewMain.add(tvResults);
Then in the callback, iterate and append to the array which is added to the view:
for(var i = 0; i < results.length; i++) {
tvResults.appendRow(createRow(results[i].deceased));
}
Note that the important piece is data : [], in the tableview; the empty array for the data property. Hope this helps someone avoid the headache this caused me.
this should work too
var sections = [];
sections[0] = Ti.UI.createTableViewSection;
for(var i = 0; i < results.length; i++) {
sections[0].add(createRow(results[i].deceased));
};
var tvResults = Ti.UI.createTableView({
backgroundColor : "white",
data : sections
});
viewMain.add(tvResults);
精彩评论