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
New Developer
Posts: 17
Registered: ‎06-29-2013
My Device: z10
My Carrier: h2o wireless

Update ListItemComponent header after list is generated

Good day

I'm developing an application where I have a long listview

 

                ListView {
                    id: list
                    objectName: "listTransactions"
                    scrollIndicatorMode: ScrollIndicatorMode.ProportionalBar
                    scrollRole: ScrollRole.Main
                    
                    listItemComponents: [
                        ListItemComponent {
                            type: "header"
                            MyCustomItemHeader {
                                text: this_text_is_based_on_long_operation_and_will_take_some_time_to_show
                            }
                        },
                        ListItemComponent {
                            type: "item"
                            Custom2ListItem {
......

 the header item will show a text, but the value of the text will be calculated and displayed later, so how can I do that? i.e. show the list view without the text, and when the text is ready, display it on its appropriate position without regenerating the list once more.

 

Hope my question makes sense, I'm open for any suggestion.

 

Thanks!

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

Re: Update ListItemComponent header after list is generated

[ Edited ]

ListView's work on the MVC model so really any changes to the list should be written back to the model data.

 

It's possible to do this in a hacky way but then you run in to having to code around the efficiencies in the list, like item reuse, etc.

 

What you are really describing is asynchronous behaviour, take a look at this for an idea of how to code for this...

 

http://developer.blackberry.com/native/documentation/cascades/ui/lists/asynch_data.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: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Update ListItemComponent header after list is generated

set text to ListItemData.headerText (as an example). When you set headerText later it will be updated in the list
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Update ListItemComponent header after list is generated

[ Edited ]

Do you only have one header item?

 

Simon's answer is one of the hacky ways I mentioned earlier but starts to get messy and cumbersome if you have more than one. No offence intended Simon, it's a good suggestion. Smiley Happy

 

If you do only have one piece of info to convey have you considered using a leadingvisual?

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__listview.html#property-leadi...

 

 


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: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Update ListItemComponent header after list is generated

why is it hacky?
If you have special list elements/objects for the header you can give them a property for the text. when the property is changed on the object in the data model it fires a changed signal and the list view updates the label on the header item.
as you can have different values set on different header items i don't see how it gets "messy and cumbersome if you have more than one".
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Update ListItemComponent header after list is generated

[ Edited ]

Perhaps I'm misunderstanding your suggestion (you did only write 19 words Smiley Happy) but I thought you were suggesting a property that would be changed on the list being completed.
As you add more headers you would need to have an array of some sort keeping track of each header to update each as the data is loaded.
The OP wants to update the header item(s) on values taken from the ListItems (I've assumed the sub-items under each header but possibly not).

 

If you are saying in your second post to write back the value to the model and then have the header updated on the signal I agree and definately not hacky as it's the suggestion I put in my first post.


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: 17
Registered: ‎06-29-2013
My Device: z10
My Carrier: h2o wireless

Re: Update ListItemComponent header after list is generated

Hello Simon

 

Thanks for the reply

 

I have implemented a GroupDataModel and its the way I use it to populate data to the listview. and the list view is then grouped by Date and then ID.

	setSortingKeys(QStringList() << "Date" << "ID");
	setGrouping(ItemGrouping::ByFullValue);

Now updating the list items is done OK. the issue is I dont know how to do that with the headers as well.

 

As the headers will be grouped by date.

 

I've tried the following

 

                        ListItemComponent {
                            type: "header"
                            MyCustomItemHeader {
                                balance: ListItemData.CalculatedValue+ "  1234";
                            }
                        },

 Where CalculatedValue is part of the response of the GroupDataModel class.

This is the output I'm getting.

 

 

Undefined 1234

 On all the headers

 

Is there anyway around this? or can I spsecify another model ONLY for the header. giving that the header is goruped from results returned by the original datamodel.

 

Thanks!

 

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Update ListItemComponent header after list is generated

the CalculatedValue should be set to something before your long running operation starts, be it an empty string or something else.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 17
Registered: ‎06-29-2013
My Device: z10
My Carrier: h2o wireless

Re: Update ListItemComponent header after list is generated

Can you give me an example? I'm stuck with this point. I've tried a few things, but nothing is working, so I would really appreciate any thing you can provide.

 

Thanks!

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Update ListItemComponent header after list is generated

please show the code where you add the header items, and show the header item object as well.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter