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
Trusted Contributor
smjose
Posts: 134
Registered: ‎04-12-2013
My Device: BB Z10
Accepted Solution

Checkbox as list Item component

Hi,

I have created a ListView with list item components as a label and a checkbox. 

When I check the checkbox on a list item, I will not get a onTrigger event from the list.  So, there is no way to see if the check box is checked or unchecked.  I need only one checkbox to be in "checked" state in the listview at a time. 

 

I tried to get the indexpath of the checkbox which is checked, and call a function to iterate through the index path. There I want to uncheck all the checkboxes other than the one which is checked now. 

CheckBox {
               id: checkBoxId
               horizontalAlignment: HorizontalAlignment.Right
               verticalAlignment: VerticalAlignment.Center
                onCheckedChanged: {
                 var rowNum = rootContainer.ListItem.indexPath;
                 count = articlesDataModel.size();
                  toggleCheckBox();
                                   }
          }
                              
            function toggleCheckBox()
                    {
                      for (var i=0 ; i< count ; i++) 
                       {
                        if(rootContainer.ListItem.indexPath[i]!= rowNum)
                         {
                          ????????
                          }
                                        
                         }
                                    
                      }  

 this is the code I tried. But, I dont know how to get the checkbox control here inside.. :smileysad: 

 

Could someone please look into this? 

 

Thanks,

SJ

Please like this if you are answered.
Developer
laairoy
Posts: 24
Registered: ‎10-31-2012
My Device: Dev Alpha B

Re: Checkbox as list Item component

You can save the checkbox status in list so when the item is clicked you get the indexPath and check the checkbox.
__
Helped you? Like me.
Trusted Contributor
smjose
Posts: 134
Registered: ‎04-12-2013
My Device: BB Z10

Re: Checkbox as list Item component

hi..

 

http://supportforums.blackberry.com/t5/Cascades-Development/radiobutton-in-list-view-problem/td-p/24...

this link helped me to solve this. Thanks :smileyhappy:

Please like this if you are answered.