Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Why does only first row in nested TableView show?

$
0
0

I have a window with a TableView where each row has it's own TableView with a few rows. But for some reason only the first row of the inner TableView shows - and I just can't for the life of me figure out why...

In the code below each inner row should have a "name" label and a "place" label. But only the "name" label shows up. Why?!

Here is the complete code so that you can try it yourself:

// Create main window with a view that contains a label
 
var mainWindow = Ti.UI.createWindow({  
    backgroundColor: 'yellow'
});
 
 
var mainView = Ti.UI.createView({
});
mainWindow.add(mainView);
 
 
var windowLabel = Ti.UI.createLabel({
    text: 'Label In Main Window',
    top: '5dp'
});
mainView.add(windowLabel);
 
var outerRows = [];
 
// Create the outer table row #1
 
var outerTableRow1 = Ti.UI.createTableViewRow({
    backgroundColor: 'red',
    className: 'rowForChrome'
});
outerRows.push(outerTableRow1);
 
var chromeView1 = Ti.UI.createView({
    backgroundColor: 'white',
    top: '5dp',  // "padding"
    bottom: '5dp',
    left: '5dp',
    right: '5dp'
});
outerTableRow1.add(chromeView1);
 
var innerRows1 = [];
innerRows1.push( createInnerRowItem('Inner Item #1: Name') );
innerRows1.push( createInnerRowItem('Inner Item #1: Place') );
 
chromeView1.add(
    Ti.UI.createTableView({
        data: innerRows1
    })
);
 
// Create the outer table row #2
 
var outerTableRow2 = Ti.UI.createTableViewRow({
    backgroundColor: 'red',
    className: 'rowForChrome'
});
outerRows.push(outerTableRow2);
 
var chromeView2 = Ti.UI.createView({
    backgroundColor: 'white',
    top: '5dp',  // "padding"
    bottom: '5dp',
    left: '5dp',
    right: '5dp'
});
outerTableRow2.add(chromeView2);
 
var innerRows2 = [];
innerRows2.push( createInnerRowItem('Inner Item #2: Name') );
innerRows2.push( createInnerRowItem('Inner Item #2: Place') );
 
chromeView2.add(
    Ti.UI.createTableView({
        data: innerRows2
    })
);
 
// Create the outer table view
 
var outerTable = Ti.UI.createTableView({
    data: outerRows,
    separatorColor: 'black',
    top: '61dp'
});
mainView.add(outerTable);
 
 
// Function for creating an inner tow
 
function createInnerRowItem(iRowName) {
    var innerRow = Ti.UI.createTableViewRow();
 
    var itemName = Ti.UI.createLabel({
        text: iRowName
    });
    innerRow.add(itemName);
 
    return innerRow;
}
 
 
mainWindow.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>