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
Posts: 97
Registered: ‎07-17-2008
My Device: Not Specified

About Listview and xmlDataModel

Hi,

 

 

I need to display only specific tag value into Listview how to display it using QML?

 

for example:

<model> <header title="A"> <contact name="Adam"> <phone number="+4623894299" /> <phone number="+4623929922" /> </contact> <contact name="Annie"> <phone number="+4654633667" /> <email address="annie@rim.com" /> </contact> </header> <header title="B"> <contact name="Bert"> <phone number="+465256467" /> <phone number="+464746734" /> <phone number="+468234892" /> </contact> </header> </model>

 

From this xml if I want to display only "contact" tags properties into listview. (i.e. Adam, Annie, Bert) then how to do it.

 

I tried different ways but not able to display it. Also How to implement persistent store in Blackberry Native SDK 10?

 

Thanks and regards,

Shubhangi

 

 

Developer
Posts: 162
Registered: ‎01-11-2012
My Device: BlackBerry 9790, BlackBerry PlayBook 64Gb, BlackBerry 10 Dev Alpha
My Carrier: MTS

Re: About Listview and xmlDataModel

Hi Shubhangi,

You should use XmlListModel and set appropriate XmlRole. Read about this here:

http://doc-snapshot.qt-project.org/4.8/qml-xmllistmodel.html
Respectfully,
Oleg

Developer, QNX RTOS, BlackBerry 10 and PlayBook
Follow me on Twitter (in Russian)
St.Petersburg BlackBerry Dev. Group
Developer
Posts: 97
Registered: ‎07-17-2008
My Device: Not Specified

Re: About Listview and xmlDataModel

Hi, Thanks for reply.

 

I checked the document. First thing I want to use this in Cascade application, also I want to have multiple selection mode functionality so as to select the specified items from the listview.

 

I tried using the model in cascade application, but the XMLListModel and XMLRole compnents are not known is displayed at the time of compilation.

 

What should be done here. I am new to Blackberry 10 development.

 

Kindly guide...

 

Thanks and regards,

Shubhangi

 

Developer
Posts: 162
Registered: ‎01-11-2012
My Device: BlackBerry 9790, BlackBerry PlayBook 64Gb, BlackBerry 10 Dev Alpha
My Carrier: MTS

Re: About Listview and xmlDataModel

To select multiple items you can add appropriate functionality to the Component that used as delegate in the ListView.

I can't check personally how XMLListModel works in Cascades. But you can use pure Qt and QML.
Respectfully,
Oleg

Developer, QNX RTOS, BlackBerry 10 and PlayBook
Follow me on Twitter (in Russian)
St.Petersburg BlackBerry Dev. Group
Highlighted
Developer
Posts: 18
Registered: ‎10-12-2012
My Device: Playbook
My Carrier: none

Re: About Listview and xmlDataModel

I have done something extremely similar in pure QML.

 

You just set the xquery in the XmlRole.

 

In your case the query would be '/model/header/contact name'

 

XmlRole { name: "title"; query: "title/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }

 

 

FYI - not a good idea to have spaces in XML tag name - I don't think this is valid xml.