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
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus
Accepted Solution

Modify ListItemComponent from outside

Hi, I'm hoping someone can help me with this.

 

I have a ListView and from my button's onClicked, I want to add checkbox to the ListItemComponents.

 

How can I achieve this? Can this even be done? The variable scope is really annoying.

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify ListItemComponent from outside

[ Edited ]

You can replace any StandardListItem with one of your own including one with a checkbox in.

 

Reading this page shows you how...

 

http://developer.blackberry.com/cascades/documentation/ui/lists/list_view.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify ListItemComponent from outside

[ Edited ]

I'm going to answer your question in a different way as well in case you already knew this and your question is more complex than first reads.

 

To access the ListItem and add a CheckBox I believe you'd have to switch in to C++ write your own ListItemProvider to update the selected item possibly using a DelegateControl or handling the adding and removing of the control to the scene yourself.

 

Without a bit more explanation or seeing code its hard to know what your scope problem is and the level of complexity you are looking for.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus

Re: Modify ListItemComponent from outside

Your second reply is a more accurate answer to my question Smiley Happy

 

In the docs (ListItemComponent), it reads

 

This class can only be used in QML. In C++, the visuals for list items can be managed using ListItemProvider.

 and in the first line of ListItemProvider, it reads

 

An interface for providing VisualNode objects as items in a ListView.

 So I guess ListItemComponent for qml doesn't allow you to control visual node as "items"? So can I conclude that there is absolutely no way for ListItemComponent to be modified from outside (of listview) signal?

 

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify ListItemComponent from outside

[ Edited ]

That's the way I read it, and I ended up switching to C++ and writing my own Provider to get around the limitations that seem to be in QML. It's not that difficult and once it's done you get a more workable and understandable level of control of the ListView.

 

Bite the bullet. Smiley Happy

 

Also I wouldn't say there is no way to modify as you can access the model and the view from within the ListItemComponent just not access from a seperate piece of logic outside of the component.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify ListItemComponent from outside

[ Edited ]

Hacky but you could always use a DelegateControl that swaps the ListView to one with checkboxes on your button press if you really wanted to avoid C++.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus

Re: Modify ListItemComponent from outside

might just do that. Thanks BBSJdev!

----------------------------------------------------------
Twitter: @gyubok