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
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook

apply one action for all items in ListView

Hello there,

 

I have a list view with custom list items. Each list item has an image. I need to be able to hide images in all list items by clicking one button. Have no idea how to do that. Could you help me plese?

 

Thanks! 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: apply one action for all items in ListView

If you have a custom list component give the ImageView an id and have the action make that id.visible: false.

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook

Re: apply one action for all items in ListView

I know how to do that within a list item. But if a button is outside the list item... Somethink like

 

Button{
// by clicking this button image with id alarmImage within all listItemComponents should be hidden.
} 

ListView {
	                id: alarmList
                    dataModel: GroupDataModel {
                        grouping: ItemGrouping.None
                    }	                
		            listItemComponents:[
		                ListItemComponent{

		                    AlarmItem {
		                        id: alarm
		                        aID: ListItemData.id
		                        aTime: ListItemData.Time
		                    }
		                }
		            ]
}

 

 

 

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: apply one action for all items in ListView

[ Edited ]

You can refer my previous post  :  How to dynamically change one item in the GroupDataModel

http://supportforums.blackberry.com/t5/Cascades-Development/How-to-dynamically-change-one-item-in-th...

 

You can add a flag into the item in GroupDatamodel, the rest thing is checking the visible flag to show or hide the image in your customized ListItem container based on the updated item.




p(^_^)q
Good good study, day day up
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: apply one action for all items in ListView

Is there any specific reason why you made a custom component AlarmItem? Why not leave it inline in the ListView?  Because if it is inline it is easier (and better coding unless you need the AlarmItem component in many places in the app)

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook

Re: apply one action for all items in ListView

I'm using it in a few places. Anyway if it is better to leave it inline in the ListView I will do so. So you suggest that would work, right?

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: apply one action for all items in ListView

[ Edited ]

You can only call YOURDATAMODEL.updateItem(indexPath, updatedItem), then the datamodel will be updated. You could not directly change the member value in your datamodel.

 

As well as, you should add a id to your groupdatamodel say alertDataList, then you can iterate by this id in the qml globally.




p(^_^)q
Good good study, day day up
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: apply one action for all items in ListView

It should, haven't tested it for myself but make sense. Post up if you have any issues.
---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: apply one action for all items in ListView

I have tried to directly update the datamodel without using the api updateitem, the ListItemData still has the old value. Then I found I have to use this API.




p(^_^)q
Good good study, day day up
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: apply one action for all items in ListView

[ Edited ]

It's not neccessary to make it inline. You can reference the image even in different component. Or expose it via property alias:

AlarmItem.qml:
property alias myImage: someImageView;

Then access it like this:

AlarmItem {
myImage.hidden: someFlag;
}

someFlag can be a flag in main QML which can be toggled when the button is pressed.

But ListItemComponents have their own visibility tree. There are additional steps involved if you need to access a property outside ot ListItemComponent.

 

Using data model for this is probably a better option.


Andrey Fidrya, @zmeyc on twitter