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

Updating listview item by clicking listview section footer view

$
0
0

How to update listview section's item by clicking a child view of section's footer view ? I tried like below but does not working ? how can i do that ?

var plainTemplate = {
 
    childTemplates : [{
        type : 'Ti.UI.Label',
        bindId : 'title',
        properties : {
            color : '#000',
            top : '3dp',
            height : '21dp',
            width : Ti.UI.FILL,
            left : '10dp',
            font : {
                fontFamily : 'Arial',
                fontWeight : 'bold',
                fontSize : '15dp'
            }
        }
    }, {
        type : 'Ti.UI.Label',
        bindId : 'count',
        properties : {
            color : '#36A9E1',
            top : '26dp',
            height : '21dp',
            width : Ti.UI.FILL,
            left : '10dp',
            font : {
                fontFamily : 'Arial',
                fontWeight : 'bold',
                fontSize : '13dp'
            }
        }
    }],
    properties : {
        height : '50dp',
        backgroundColor : '#FFF'
    }
};
 
// Function to create a view with a label
var createCustomView = function() {
    var view = Ti.UI.createView({
        backgroundColor : '#222',
        height : 40
    });
    var likeIcon = Ti.UI.createImageView({
        image : 'like_blur@2x.png',
        left : '5dp',
        width : '15dp',
        height : '15dp'
    });
    view.add(likeIcon);
    return view;
};
 
var win = Ti.UI.createWindow({
    backgroundColor : 'white',
    fullscreen : true
});
var listView = Ti.UI.createListView({
    width : Ti.UI.FILL,
    height : Ti.UI.FILL,
    templates : {
        'plain' : plainTemplate
    },
    defaultItemTemplate : 'plain'
});
 
for (var i = 0; i < 3; i++) {
 
    var section = Ti.UI.createListSection({
        footerView : createCustomView()
    });
 
    section.setItems([{
        title : {
            text : 'Title ' + i
        },
        count : {
            text : i * 10
        }
    }]);
 
    listView.appendSection(section);
}
 
win.add(listView);
win.open();
 
listView.addEventListener('itemclick', function(e) {
    /*if the image of section footer is clicked then i want to update the count item (blue text) of each section, but how ? Below code does not working at all.*/
 
    var item = e.section.getItemAt(e.itemIndex);
    item.count.text = 1;
    e.section.updateItemAt(e.itemIndex, item);
    Ti.API.info(e);
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles