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
Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel
Accepted Solution

In Group data model when list count 1 then data does not show in list field

[ Edited ]

I have a Xml file contacts.xml ,that content is below...

 

<contacts version="1.0">
<contact>
<id>1</id>
<title>Sr. Editor</title>
<firstname>Mike</firstname>
<lastname>Chepesky</lastname>
<phonenumber></phonenumber>
</contact>
</contacts>

 

In cpp I just do below code

 

GroupDataModel *model = new GroupDataModel();
XmlDataAccess xda;
QVariant list = xda.load(
QDir::currentPath() + "/app/native/assets/contacts.xml",
"/contacts/contact");

model->insertList(list.value<QVariantList>());

QStringList key;
key << "id";
model->setSortingKeys(key);
model->setSortedAscending(FALSE);

listView->setDataModel(model);

 

When that XML have more then one chilled then data show in listview but when one chilled the data does not show.

Please help me...... 

 

Mod Edit: Removed personal information to comply with Community Guidelines and Terms and Conditions of Use.

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: In Group data model when list count 1 then data does not show in list field

[ Edited ]

I'm not 100% sure, but I think if there's only 1 element it may be treating it as a map. So, something like this may be needed (untested):

 

QVariant list = xda.load(
QDir::currentPath() + "/app/native/assets/contacts.xml",
"/contacts/contact");

QVariantList l = list.value<QVariantList>();
if (l.isNull())
  model->insert(list.value<QVariantMap>());
else
  model->insertList(list.value<QVariantList>());

Please tell if it works. If so, the docs should be updated to include this case.

 


Andrey Fidrya, @zmeyc on twitter
Highlighted
Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: In Group data model when list count 1 then data does not show in list field

[ Edited ]

Hi Sumitava_Datta,

 

Please report this issue in jira (Developer Issue Tracker). 

 

I confirm that Zmey's solution works. I have tried it myself and it does indeed provide a workaround to this bug. Just use isEmpty() instead of isNull(), which is not recognized as a valid QVariantList function.

 

QVariant list = xda.load(
QDir::currentPath() + "/app/native/assets/contacts.xml",
"/contacts/contact");

QVariantList l = list.value<QVariantList>();
if (l.isEmpty())
  model->insert(list.value<QVariantMap>());
else
  model->insertList(list.value<QVariantList>());

 

 

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: In Group data model when list count 1 then data does not show in list field

Hi sabdelsayed,

 

Thanks for your reply . Can you provide the link to post on jira?

Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: In Group data model when list count 1 then data does not show in list field

Link to jira: https://www.blackberry.com/jira/secure/Dashboard.jspa
@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: In Group data model when list count 1 then data does not show in list field

Thanks...........