Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1012] table view row painting issue when changing row data

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:57.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:41:29.000+0000
Updated2011-04-17T01:54:57.000+0000

Description

when you click a row the bg color for the row is changed and hasCheck is set to true. if you click it again, the row bg color goes back to white and hasCheck is false. the issue is that some rows become grey when not clicked - seems to be row repaint issue. here's the code:

var win = Titanium.UI.createWindow();

//win.row = null;

    var inputData = [ 
        {title:'Children', leftImage:'icons/children.png', backgroundColor:'#fff', test:'children.js', header:'C'},
        {title:'Coffee', leftImage:'icons/coffe.png', backgroundColor:'#fff', test:'coffe.js'},          
                     
        {title:'Dating', leftImage:'icons/dating.png', backgroundColor:'#fff', test:'dating.js', header:'D'},
        {title:'Diabetes', leftImage:'icons/diabetes.png', backgroundColor:'#fff', test:'diabetes.js'},
        {title:'Diet', leftImage:'icons/diet.png', backgroundColor:'#fff', test:'goals.js'},
        {title:'Dream', leftImage:'icons/cloud2.png', backgroundColor:'#fff', test:'dreams.js'},
        {title:'Driving', leftImage:'icons/driving.png', backgroundColor:'#fff', test:'goals.js'},
        
        {title:'Fotboll', leftImage:'icons/fotboll.png', backgroundColor:'#fff', test:'goals.js', header:'F'},
        
        {title:'Game', leftImage:'icons/games.png', backgroundColor:'#fff', test:'goals.js', header:'G'},
        {title:'Gift', leftImage:'icons/gift.png', backgroundColor:'#fff', test:'gift.js'},
        {title:'Golf', leftImage:'icons/golf.png', backgroundColor:'#fff', test:'golf.js'},
        
        {title:'Headache', leftImage:'icons/zap.png', backgroundColor:'#fff', test:'headache.js', header:'H'}, 
        
        {title:'Location', leftImage:'icons/map.png', header:'L'},
        
        {title:'Medicin', leftImage:'icons/pills.png', backgroundColor:'#fff', test:'medicine.js', header:'M'},
        {title:'Money', leftImage:'icons/economy.png', backgroundColor:'#fff', test:'goals.js'},
        {title:'Music', leftImage:'icons/music.png', backgroundColor:'#fff', test:'goals.js'}, 
        {title:'My pain', leftImage:'icons/pain.png', backgroundColor:'#fff', test:'pain.js'},
        
        {title:'Outfit', leftImage:'icons/tshirt.png', backgroundColor:'#fff', test:'outfit.js', header:'O'}, 
        
        {title:'Pet', leftImage:'icons/pet.png', test:'pet.js', header:'P'},
        {title:'Poker', leftImage:'icons/poker.png', backgroundColor:'#fff', test:'goals.js'},
        {title:'Pregnancy', leftImage:'icons/baby.png', backgroundColor:'#fff', test:'goals.js'},
        
        {title:'Sport', leftImage:'icons/sport.png', backgroundColor:'#fff', test:'goals.js', header:'S'},
        {title:'Smoking', leftImage:'icons/smoke.png', backgroundColor:'#fff', test:'smoking.js'},
        
        {title:'Training', leftImage:'icons/bicyckling.png', test:'training.js', header:'T'},
        
        {title:'Water', leftImage:'icons/water.png', backgroundColor:'#fff', test:'water.js', header:'W'},
        {title:'Worktime', leftImage:'icons/working.png', backgroundColor:'#fff', test:'clockin.js'},

        //{title:'Make your own diary', leftImage:'icons/diet.png', header:'', leftImage2:'icons/empty.png', backgroundColor:'#fff'},
        {title:'New diaries requests', header:'', hasChild:true},   
        {title:'Special group requests', hasChild:true} 
    ];

var tableview = Titanium.UI.createTableView({
    data:inputData,
    editable:true,
    //backgroundColor:'transparent',
    title:'Diary library',
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED
    });

var c=0;
var y=0;
// create table view event listener
tableview.addEventListener('click', function(e)
{
    // event data
    var index = e.index;
    var row = e.row;
    Ti.API.info('row ' + index + ' bgColor ' + row.backgroundColor)
    if (row.backgroundColor != '#E2E2E2' && index<26)
    {   
        var color = '#E2E2E2';
        row.className = 'checked';
        row.backgroundColor = color;
        row.hasCheck = true;

    }
    else
    {
        row.backgroundColor = '#fff';
        row.hasCheck = false;
        row.className = 'no_check'
    }
    
});

win.add(tableview);

win.open();

Comments

  1. Jeff Haynie 2011-04-15

    (from [90e432f60a3734bf17b3b57f63f86985b88b29d0]) Closes #1012 . TableRows with an invalid or null background color have white applied instead instead of leaving them unchanged. http://github.com/appcelerator/titanium_mobile/commit/90e432f60a3734bf17b3b57f63f86985b88b29d0"> http://github.com/appcelerator/titanium_mobile/commit/90e432f60a373...

JSON Source