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
Highlighted
Contributor
Posts: 23
Registered: ‎08-01-2013
My Device: Z10
My Carrier: T-Mobile
Accepted Solution

ListView, header title change based on stored value.

Hello,

 

I'm new to native development, still trying to get a hang of how things are done in QML. I was wondering how it was possible to format the header in ListView based on the header value. For example, the datamodel is sorted by Status and Name. Status is stored as an integer 0,1,2,3,4,5 in the database. Whenever the ListView displays the headers, I'd like to show the actual title of the Status (eg Pending, Completed) instead of showing 0 or 1.

 

Thank you for your help.

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

Re: ListView, header title change based on stored value.

Not sure this is really a ListView question more like a C++ or QML question.

 

In C++ you can define an enum and then read the enum corresponding to the number returned.

 

In QML you could do a simple switch statement.

 


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.
Contributor
Posts: 23
Registered: ‎08-01-2013
My Device: Z10
My Carrier: T-Mobile

Re: ListView, header title change based on stored value.

I tried in qml with if else but it gave errors. Glad to hear switch can work. Thank you
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView, header title change based on stored value.

If ... else if ... else should have worked as well, please post your code.


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.