UITableView not ordered right. Problem.

You must Login before you can answer or comment on any questions.

Hi, I have made a UITableView with custom rows in it and its not rendering right. The data is reversed and headers aren't showing up. What I mean is, if the data is:

var appData = [
    {header:'Info',title:'Version:',subtitle:Titanium.Platform.version},
    {title:'Model:',subtitle:Titanium.Platform.model},
    {title:'Username:',subtitle:Titanium.Platform.username},
];
The header will not show up, and instead of it being "Version, Model, Username", it will end up being "Username, Model, Version" on the screen. What do I do? I'm at a loss. Full Code below:
var win = Titanium.UI.currentWindow;
//
//load local xml file
//
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,'tabledata.xml');
var xmltext = file.read().text;
var doc = Ti.XML.parseString(xmltext);
//
//get data from xml file and store in a list
//
var titleList = doc.documentElement.getElementsByTagName("data");
 
//
//create an array and save the data into array
//
var LocationData = [];
 
for(var i = 0; i<titleList.length;i++)
{
    LocationData[i] = JSON.parse(titleList.item(i).text);
}
 
var search = Titanium.UI.createSearchBar(); 
 
var tableview = Titanium.UI.createTableView({
    data:LocationData,
    // search:search,
    // searchHidden:true
});
 
 
 
 
// create table view event listener
tableview.addEventListener('click', function(e)
{
    if (e.rowData)
    {
        var win = Titanium.UI.createWindow({
            url:e.rowData.link,
            // title:"Hello",
            title:e.rowData.title,
        });
 
        // create table view data object
var appData = [
    {header:'Info',title:'Version:',subtitle:Titanium.Platform.version},
    {title:'Model:',subtitle:Titanium.Platform.model},
    {title:'Username:',subtitle:Titanium.Platform.username},
];
 
        // create table view
        var tableview = Titanium.UI.createTableView({
            data:appData,
            separatorColor: '#999',
            allowsSelection:false,
            touchEnabled:true,
            style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
        });
 
 
var data=[];
 
for (var i = appData.length - 1; i >= 0; i--){
 
    var row = Titanium.UI.createTableViewRow();
 
    var title = Titanium.UI.createLabel({
        text:appData[i].title,
        font:{fontSize:16,fontWeight:'bold'},
        width:'auto',
        textAlign:'left',
        top:14,
        left:10,
        height:16
    });
 
    var subtitle =  Titanium.UI.createLabel({
        text:appData[i].subtitle,
        font:{fontSize:16,fontWeight:'normal'},
        width:'auto',
        textAlign:'right',
        top:14,
        right:11,
        height:16,
        color:'#496691'
    });
 
    // var uuid =  Titanium.UI.createLabel({
        // text:appData[i].uuid,
        // font:{fontSize:13,fontWeight:'normal'},
        // width:'auto',
        // textAlign:'center',
        // top:0,
        // bottom:0,
        // right:0,
        // left:0,
        // color:'#496691'
    // });
 
    row.add(title);
    row.add(subtitle);
    // row.add(uuid);
    row.hasChild=appData[i].hasChild;
    row.className = 'platform_row';
 
 
    data.push(row);
};
 
 
tableview.setData(data);
 
 
 
 
 
 
 
 
 
 
 
        win.add(tableview);
        Titanium.UI.currentTab.open(win,{animated:true});
    }
});
 
// tableview.index= [ {title: 'A', index: 0}, {title: 'B', index: 1} ]
 
 
 
 
 
 
 
 
win.add(tableview);
win.open();

1 Answer

Your Answer

Think you can help? Login to answer this question!