Parent Window Displays Always Same Dynamic Table View--Titanium Iphone

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

Hello communityI am newbie to titanium development and creating a new project which show home window and then display a Main window with 3 tabs--Home, News, Contact. I display data from Titanium Database and also updates database tables after a time interval, when i show data from Titanium database first time it displays data in tableview. When i click, blur, open, focus(I tried every thing) on any tab it select rows from database but "ALWAYS DISPLAY SAME TABLE VIEW IN News Page". I have tried everything setData([]), setTimeout to refresh Table view but still displays same Table View but when i remove or hide it works fine every time,I want to refresh Main window Table view. Any help will be appreciatable!!

var newsCon =Ti.UI.currentWindow; console.log("news_content");

showNewsPageContent(); function showNewsPageContent(){

console.log("showNewsPageContent"); var inputData =[]; var dbObj = Ti.Database.open('ForEvent'); var rows = dbObj.execute('SELECT * FROM newsfeed ORDER BY post_modified DESC');

Ti.API.info('Row count: ' + rows.rowCount);
var fieldCount;

if (Ti.Platform.name === 'android') {
    fieldCount = rows.fieldCount;
} else {
    fieldCount = rows.fieldCount();
}
Ti.API.info('Field count: ' + fieldCount);

while (rows.isValidRow()){
    //alert("1");
  Ti.API.info('Title' + rows.fieldByName('post_title'));



           var row = Ti.UI.createTableViewRow();

           row.customId =rows.fieldByName('post_id');
           row.hasChild =true;
            var label = Ti.UI.createLabel({
                left: 100,
                text:rows.fieldByName('post_title')
            });
            var image = Ti.UI.createImageView({
                image: Ti.Utils.base64decode(rows.fieldByName('post_featimage')),
                left: 5,
                width:75,
                height:60

            });

            row.add(label);
            row.add(image);

            inputData.push(row);


   rows.next();
 }

             var newsCon_view = Titanium.UI.createTableView();

             newsCon_view.setData([]);
             newsCon_view.setData(inputData);
             newsCon.add(newsCon_view);

rows.close();
dbObj.close();

}

function displayNewsDetail(e) { //alert("hello"); var rowdata = e.rowData; Ti.API.info(rowdata.customId); var newsWin = Ti.UI.createWindow({ title:'News Detail', backgroundColor:'#fff', url:'news_detail.js' }); newsWin.post_id =rowdata.customId; Ti.UI.currentTab.open(newsWin, {animated:true});

}

Nothing is working

— asked 10 months ago by jitendra kumar
1 Comment
  • var newsCon = Ti.UI.currentWindow;
    console.log("news_content");
    showNewsPageContent();
    function showNewsPageContent() {
        console.log("showNewsPageContent");
        var inputData = [];
        var dbObj = Ti.Database.open('ForEvent');
        var rows = dbObj.execute('SELECT * FROM newsfeed ORDER BY post_modified DESC');
        Ti.API.info('Row count: ' + rows.rowCount);
        var fieldCount;
     
        if (Ti.Platform.name === 'android') {
            fieldCount = rows.fieldCount;
        } else {
            fieldCount = rows.fieldCount();
        }
        Ti.API.info('Field count: ' + fieldCount);
     
        while (rows.isValidRow()) {
            //alert("1");
            Ti.API.info('Title' + rows.fieldByName('post_title'));
     
            var row = Ti.UI.createTableViewRow();
     
            row.customId = rows.fieldByName('post_id');
            row.hasChild = true;
            var label = Ti.UI.createLabel({
                left : 100,
                text : rows.fieldByName('post_title')
            });
            var image = Ti.UI.createImageView({
                image : Ti.Utils.base64decode(rows.fieldByName('post_featimage')),
                left : 5,
                width : 75,
                height : 60
     
            });
     
            row.add(label);
            row.add(image);
     
            inputData.push(row);
     
            rows.next();
        }
     
        var newsCon_view = Titanium.UI.createTableView();
     
        newsCon_view.setData([]);
        newsCon_view.setData(inputData);
        newsCon.add(newsCon_view);
        rows.close();
        dbObj.close();
    }
     
    function displayNewsDetail(e) {
        //alert("hello");
        var rowdata = e.rowData;
        Ti.API.info(rowdata.customId);
        var newsWin = Ti.UI.createWindow({
            title : 'News Detail',
            backgroundColor : '#fff',
            url : 'news_detail.js'
        });
        newsWin.post_id = rowdata.customId;
        Ti.UI.currentTab.open(newsWin, {
            animated : true
        });
    }

    — commented 10 months ago by Sahil Grover

Your Answer

Think you can help? Login to answer this question!