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

Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Suggestion on DataModel for ListView



I may have a ListView implemented in C++ with following features.


Some of its data is static. Some of its data may come from run time, e.g., internet, server.

I want the ListView to support headers. But I don't want the headers to be sorted.


Which would be your recommendations as to which DataModel to use?

Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: Suggestion on DataModel for ListView

You will need to make your own, derived from the DataModel base class
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: Suggestion on DataModel for ListView

Any samples for that? I think I can use XMLDataModel -- I think it is possible to use it in C++ right? it allows to have unsorted headers (I was just having some translation issue with it, but I think I know how to resolve it too). What is your opinion?
Posts: 45
Registered: ‎04-11-2012
My Device: Z10 Limited Edition
My Carrier: 00201003883386

Re: Suggestion on DataModel for ListView

Check this example of creating custom data model:

When you are young, work to learn. Not to earn !
New Contributor
Posts: 3
Registered: ‎03-18-2013
My Device: 9900
My Carrier: att

Re: Suggestion on DataModel for ListView

If you have something coming over the internet, i guess XmlDataModel should be your best bet. All you need to do is set your ListView's dataModel to theXmlDataModel object. 

Store the xml file you receive from server to the assets folder or some other folder where your app have access to read the file. 

Create a xmldataobject  using this data - 

XmlDataModel *object = new XmlDataModel();

object-> setSource("your file location");


You can then use it in a ListView to show the data


Posts: 285
Registered: ‎08-06-2010
My Device: Z10

Re: Suggestion on DataModel for ListView

I ran in to a similar problem and this is quite common in a number of different platforms.


My solution is to include a header (recreate the header through the use of a background image and text) in EACH row and set its visibility to false by default.  As you're adding the items to your list, filter out which rows you would like to have a row above, and set the visibility of that row's header to true.

Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples