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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

Re: getting wrong text for items in ListView

@zmey beat me to it. Smiley Happy


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.
New Developer
Posts: 15
Registered: ‎08-12-2013
My Device: Z10
My Carrier: Vodafone

Re: getting wrong text for items in ListView

Unfortunatley setting


expandableMessage.headerTextVisible.visible = true;
expandableMessage.bodyTextVisible.visible = false;

 

in ListItem.onDataChanged and adding to expandablelabel

 

property alias headerTextVisible: lblTitle.visible
property alias bodyTextVisible: lblBody.visible

 

doesn't fix it, I'm at a loss. I am not getting any qml errors in the console when ondatachnaged is called.

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: getting wrong text for items in ListView

[ Edited ]

Could you verify that onDataChanged is getting called at all? (by adding a console.log() statement to it)

It will work only when defined at top level item of ListItemComponent.

 

By the way, directly modifying ListItemComponent properties such as
lblBody.visible = true;
won't work because ListView reuses these ListItemComponents as it sees fit. It will rearrange them during scrolling and their state will be lost.

 

How many items do you need to display? Sometimes it's easier to simply add them to a Container without using ListView at all.

 

When using ListView, it's better to create a model with all the needed flags (isExpanded etc) and map visual components state to model properties. When state has to be changed, modify the model accordingly. ListView will display the new state. This has some limitations though. I had problems with updating DropDown component using this approach. Smiley Sad

 


 

UPD: thread with some sample code. Works for 'title' property, but I was unable to update DropDown's values:

http://supportforums.blackberry.com/t5/Native-Development/Getting-list-item-from-the-ListView-issue/...

I don't know if it will work when binding to 'visible' property.

 


Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 15
Registered: ‎08-12-2013
My Device: Z10
My Carrier: Vodafone

Re: getting wrong text for items in ListView

onDataChanged is definatly being called.

 

lblBody.visible is being set through an alias I added to explanablelabel  when ondatachanged is called - is that wrong?

 

The ListView is populated dynamically and needs to load more and more items when it reaches the end of the data.

 

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: getting wrong text for items in ListView

Aliases are just syntactic sugar. Using them won't change anything.

ListView works with
1) model, which contains the data
2) visual items - ListItemComponents

All data (including expanded/collapsed state etc) should reside in model. ListItemComponents should directly bind to that data.

When anything needs to be changed, model should be modified, not ListItemComponents themselves.

Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 15
Registered: ‎08-12-2013
My Device: Z10
My Carrier: Vodafone

Re: getting wrong text for items in ListView

Ok thanks, I'm starting to realise this - I just thought something as simple as editing the text or visibility wouldnt require an update to the actual object in the model, that thought cost me hours of wasted time!