Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Can't change ListItemData property

[ Edited ]

I have a list item that I can't seem to change its property. I initialize the listitem as true within cpp.  Within the checkbox  I set the listitemdata = false but it displays as true in the console.  Am I missing something?


The extra jave calls are to overcome the  context issue as described here:



This is anim item

Container {
    property alias checked: animCheckBox.checked
    id: toplvl

    gestureHandlers: [
        TapHandler {
            onTap: {
                checked = ! checked
                ListItemData.checked = checked
                animlistItem.ListItem.view.saveValueFor(ListItemData.title, ListItemData.checked)
    Container {
        id: animContainer
        CheckBox {
            id: animCheckBox
            checked: animlistItem.ListItem.view.getValueFor(ListItemData.title, true)

            // When the checked state changes for the CheckBox a signal is
            // caught in this slot function and we print a status to the the console.
            onCheckedChanged: {
                ListItemData.checked = checked;
                console.log("checkedchange objectName  :" + ListItemData.title +checked+ListItemData.checked); //true
                animlistItem.ListItem.view.saveValueFor(ListItemData.title, checked)
            function setchecked(){
        Label {
            id: animLabels
            text: ListItemData.title



 Here is the main.qml


ListView {
    id: animList
    objectName: "animList"
    // This data model will be replaced by a Qlistdata model when the application starts,
    // an XML model can be used to prototype the UI and for smaller static lists.
    dataModel: XmlDataModel {
        source: "models/anims.xml"
    listItemComponents: [
        ListItemComponent {
            type: "listItem"
            AnimItem {
                id: animlistItem
               checked: animlistItem.ListItem.view.getValueFor(ListItemData.title, true)
    function itemType(data, indexPath) {
        return 'listItem';
    function getValueFor(objectName, cond) {
        console.log("getvalue :" + objectName)
        return _tiledApp.getValueFor(objectName, cond)
    function saveValueFor(objectName, cond) {
        console.log("setvalue :" + objectName)
        return _tiledApp.saveValueFor(objectName, cond)



If you find my post helpful please "like" it and "accept as a solution"