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.
12-25-2012 12:45 AM
I'm using GoupDataModel to show data in ListView.
Now I need to find record(s) in the list, can any body help me to loop throgh the datamodel to get the indexPath? I've tried to use datamodel.find(), but it doesn't work.
Thanks in advanced.
12-25-2012 01:38 PM
indexPath is a simple JS array, where first element have a index.
var indexPath = new Array(); indexPath = 0; // get first element of DataModel var item = dataModel.data(indexPath);
12-26-2012 02:26 AM
So how I can search an indexpath which content is alike a keyword in groupdatamodel.
Example: I have a listview contains all of the name of country in the world. How do i get the indexPath of Singapore and make the listview scroll to Singapore.
12-26-2012 07:14 AM
DataModel has childCount method so just iterate elements from 0 to childCount - 1.
You can create indexPath for each element then request data using .data method.
Once you know indexPath of required element, use ListView's scrollToItem method.
Another approach is to filter the data based on search string then repopulate the DataModel, so only relevant entries are shown.
You can also create another DataModel which will expose only a subset of original DataModel:
03-07-2013 05:50 PM - edited 03-07-2013 05:51 PM
Hi, I have similar problem http://supportforums.blackberry.com/t5/Cascades-De
Are you found solution?
03-09-2013 08:54 AM - edited 03-09-2013 08:58 AM
1) Add a function to your DataModel class that returns an index path of a data item. Since the internals of DataModel are fully customizable, you can create any logic you want for defining index paths, just as long as the function uses logic that complements the data() function.
2) Expanding on Zmey's point, iterate through the DataModel children recursively until you find the object you are looking for. Keep track of the path while you search.
Get the DataModel from your ListView using dataModel(). Get the data qvariant from your ListItem using ListItem.data(). In the DataModel there are the childCount() and data() methods that you can use to iterate through all the objects in your data model. Check to see if the data() returns the same value of your ListItem.data(). If it does, you know you have the right indexPath - if not you have to try another indexPath.
There might be better, more direct ways but these should work. Option #1 is the most efficient but option #2 might be necessary if you can't change your DataModel definition.