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

access list item component outside listview

Hi,

I would like to know if it is possible to access a list item component outside the listview.

 

In my case, I have a  label and a checkbox in the listview. I have another button outside the listview. When I press this button, I should show a pop up or say, a system dialog with the label text in the listview.  

 

I also need to uncheck the checkbox in the listview when this outside button is pressed. I tried this way.. gave a id for the chckbox and declared it as Qt.myCheckBox. And then accessed this one inside the onTriggered event of the outside button. but that dint work. 

 

Any solution would be really appreciated..  Urgently needed.

 

Thanks ..

Please like this if you are answered.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: access list item component outside listview

[ Edited ]

It's not possible because ListItemComponents can be reused for different dataModel items, so their existence is not guaranteed.

 

The preferred way to change ListItemComponent is to update the item in model with the new data.

 

You can also bind controls inside of ListItemComponents to a property outside. You'll need a proxy function defined in ListView{} to access outer controls. For example (pseudocode):

property bool checkboxValue

ListView {
listItemComponents: [ ListItemComponent { id: root SomeOtherComponent {
someField: root.ListItem.view.checkboxValueProxy() }
} ] function checkboxValueProxy() { return checkboxValue } }

 

upd:  methods for updating the model are named differently depending on datamodel type. Some sample code:

http://supportforums.blackberry.com/t5/Cascades-Development/QML-ListView-update-item-on-data-model-c...

ListItemComponents will be refreshed automatically when model items are updated.

 


Andrey Fidrya, @zmeyc on twitter
Trusted Contributor
smjose
Posts: 134
Registered: ‎04-12-2013
My Device: BB Z10

Re: access list item component outside listview

Thank You. How do I bind controls inside of listItemComponents to a property outside? I did not quite understand it.

 

Also, how can I update the item model? Would be really helpful if you could point me to some code example.

 

Thanks again..

Please like this if you are answered.