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
Support_bpomatrix
Posts: 17
Registered: ‎01-09-2014
My Device: BB10

Provide dynamic height to list view?

I am creating a page with nested lists. For this, I am using “ListView” in qml file populated with data model of my C++ file. AND List’s content is dynamic which is binded with data model.

 

My problem is, only first inner list is visible to me because  Inner list is taking whole height and I am unable to see other items(other outer lists) on the page.

The problem can be solved if I will give static ‘preferredHeight’ as 100, 200 or any digit. But, I want dynamic height to lists according to item count.

 

Is there any solution to give dynamic height to inner lists?

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

Re: Provide dynamic height to list view?

Welcome to the forums.

 

I haven't checked with the latest OSs but Lists within Lists used to have several problems associated with them such as scrolling issues.

 

Have you tried removing all height properties?

 

Alternatively you can count the number of items you have in each list and set the height dynamically if you know the height of each ListItem.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Provide dynamic height to list view?

Just out of curiosity, why do you want embedded lists?

 

You can do some pretty crazy stuff with custom DataModels and ListItemComponents. For example, check out this sample: http://blackberry.github.io/Cascades-Samples/filtereddatamodel.html

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Support_bpomatrix
Posts: 17
Registered: ‎01-09-2014
My Device: BB10

Re: Provide dynamic height to list view?

Hi,

Thanks for your reply.

I have also tried by removing all height properties. In this case, it is taking all height and other items are not visible.

 

As per your solution to get the number of items, how can I count the items when I am using dataModel and this can contain any number of values?

If you want sample code, then also I can post in my reply.

By the way my code format is as follows (in qml):

 

ListView {

                dataModel: dataModel1

 

listItemComponents: ListItemComponent { // List Item Component for dataModel1

                            Container {

ListView {

                                                                           dataModel: ListItemData.dataModel2

                                                                            listItemComponents: ListItemComponent {

                                                                                                ----Any Content----

                                                                                                // THIS LIST IS TAKING WHOLE HEIGHT L

                                                                           }

                                                                }

                                                }

}

}

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

Re: Provide dynamic height to list view?

Can you answer Paul's question?

Personally, from experimenting, I would avoid Lists within Lists if at all possible.

 

Are you using the same model for all the ListViews then, I would also recommend against that as well.

 

If you have separate models then you can get the count from the dataModel's childCount function...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__datamodel.html#function-chil...


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Support_bpomatrix
Posts: 17
Registered: ‎01-09-2014
My Device: BB10

Re: Provide dynamic height to list view?

Hi BBSJdev, As per your reply, I would like to answer Paul question. I required nested lists because I haven't used simple strings as list items. Instead, I have created custom containers which will be added to list. Also, inner list will contain another custom containers. So I am using nested listing concepts as I mentioned in my previous reply. The sample provided by Paul is very good but I didn’t find it appropriate as per my requirements. So please suggest me any other way to achieve my purpose. And I will not get stuck in it.

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

Re: Provide dynamic height to list view?

Could you post a snippet of your datasource and how you would like to see it formatted?


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Support_bpomatrix
Posts: 17
Registered: ‎01-09-2014
My Device: BB10

Re: Provide dynamic height to list view?

Hi BBSJdev,

 

Thanks for showing your interest. I am feeling very sorry to say, but I am not able to post snippet of code because of my company’s privacy Policies.

But I would like to share some thing with you is – Just now I got 1 solution to calculate height of list by using ‘ListItemData.modelItem2.childCount(ListItemData.modelItem2) * 200’ in preferredHeight property of inner list. And I am getting dynamic height using it.

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

Re: Provide dynamic height to list view?

Okay, I understand, it sounds like you have *a* solution anyway so please mark this thread as closed by Accepting the post that helped you the most as the solution.


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

Developer of stokLocker, Sympatico and Super Sentences.