在Titanium for iPhone中,如何从表格视图转换为详细视图。

时间:2011-08-09 13:15:45

标签: javascript iphone objective-c cocoa-touch titanium

我已经创建了一个表视图,并希望当我单击一个单元格时,会出现一个新窗口,我的单元格数据应该显示在该窗口中!!!! ....

这里我的代码是......

var table1 = Titanium.UI.createTableView(
{
    data:[
        {title:"Row 1 - simple row"},
        {title:"Row 2 - Having child", hasChild:true},
        {title:"Row 3 - with Details",hasDetail:true},
        {title:"Row 4 - with Check",hasCheck:true},
        {title:"Row 5 - red background",backgroundColor:"#f00"}
    ]
});

table1.addEventListener('click', function(e){
    if (e.rowData)
    {
        var win5 = Titanium.UI.createWindow({
            //url:e.rowData.test,
            title:e.rowData.title
        });
        win5.open();
    }
})

win1.add(table1);

1 个答案:

答案 0 :(得分:0)

var table1 = Titanium.UI.createTableView(
{
data:[
    {title:"Row 1 - simple row", url:"<Specify the whole path of your detail.js file>"},
    {title:"Row 2 - Having child", hasChild:true, url:"<Specify the whole path of your detail.js file>"},
    {title:"Row 3 - with Details",hasDetail:true, url:"<Specify the whole path of your detail.js file>"},
    {title:"Row 4 - with Check",hasCheck:true, url:"<Specify the whole path of your detail.js file>"},
    {title:"Row 5 - red background",backgroundColor:"#f00", url:"<Specify the whole path of your detail.js file>"}
]
});

table1.addEventListener('click', function(e){
if (e.rowData)
{
    var win5 = Titanium.UI.createWindow({
        url:e.rowData.url,
        title:e.rowData.title
    });
    win5.open({animated:true});

}
})

win1.add(table1);

希望这会对你有所帮助。