Welcome!

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

Reply
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All
Accepted Solution

How to iterate all the Checkbox status in a ListView

I have a ListView with CheckBox on each row. I want to realize a functionality to remember the CheckBox status if the users checked some one. 

 

I tried to use a signal when the CheckBox is checked to notify a function in a CPP to remember the current check box status but when I want to refer with the context property object registed of that CPP, it always say this  object can not be found.

 

Do you know how to realize this kind of functionality? Or how to iterate all the checkbox in the ListView? Thank you so much.

 

 

listItemComponents: [
    ListItemComponent {
        type: "textItem"
            TextItem {
                id: textitem                            
                onItemcheck: {                                
                    _app.setCheckboxStatus(checkBoxId); //ReferenceError Can not find variable _app
                }                
            }
     }                                                            
]

mainApp.cpp: qml->setContextProperty("_app", this);

TextItem.qml: 
        signal itemcheck(string checkBoxId)

        CheckBox {
          onCheckedChanged: {
            if (checked)
                itemcheck(ListItemData.id);
          }
        }

 

 

 




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon
My Carrier: Play

Re: How to iterate all the Checkbox status in a ListView

 

to resolve referance error pls do folowing

 

 

listItemComponents: [
    ListItemComponent {
        type: "textItem"
            TextItem {
                id: textitem                            
                onItemcheck: {                                
                   textitem.ListItem.view.setCheckboxStatus(checkBoxId);
                }                
            }
     }                                                            
]

function setCheckboxStatus(checkBoxId)
{
 _app.setCheckboxStatus(checkBoxId); 
}

 

Add setCheckboxStatus function to ListView

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How to iterate all the Checkbox status in a ListView

With your solution, this issue is fixed. Thank you so much.




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How to iterate all the Checkbox status in a ListView

May you also be able to show the reference of your solution? I am wondering I could learn more stuff by that reference.  Thank you.




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon
My Carrier: Play

Re: How to iterate all the Checkbox status in a ListView

I don't have any referance source code for you. :smileysad:

 

from https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html

 

"

ListItemComponent is a QML template that's used by the ListView to present data from the model. A ListItemComponent can be attached to a list view using theListView::listItemComponents property, and it can contain whatever visual controls that you want to display in your list item.

If item visuals are created from a ListItemComponentListView makes the following properties available on the root element of the item visual:

 

  • ListItem.initialized - States whether the item visual is initialized or not. true when initialization of the item visual is finished (all properties have been updated to reflect the current item),false when the item visuals become disconnected due to recycling. Explicit animations etc must not be started when the value of initialized is false.

  • ListItem.data - The QVariant returned by DataModel::data() for this item. Typically aQVariantMap or QObject* which means that data has properties of its own (e.g.ListItem.data.firstName), but could also be just a QString if that's the kind of QVariantthe currently connected DataModel returns.

  • ListItem.indexInSection - The index for this item amongst its siblings. The siblings are those items that have the same parent as this item.

  • ListItem.indexPath - The index path identifying this item in its DataModel.

  • ListItem.sectionSize - The number of child items that the parent item of this item has.

  • ListItem.view - The ListView in which this item is visible. The item is in a context separate from the ListView, so any symbols from the ListView context that are to be accessible from items must be placed as dynamic properties on the ListView.

  • ListItem.component - The ListItemComponent that this item visual has been created from. The item visuals are in a context of their own, so any symbols from the ListItemComponentcontext that are to be accessible from item visuals must be placed as dynamic properties on theListItemComponent.

  • ListItem.active - true if this item is active, false otherwise. An item is typically active if the user is holding a finger on it.

  • ListItem.selected - true if this item is selected, false otherwise. An item is typically selected if the user intends to access details for the item, or to perform an action on the item.

"

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How to iterate all the Checkbox status in a ListView

I am so appreciated with your detail reference. It is just what I need. 




p(^_^)q
Good good study, day day up
Please use plain text.