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
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Access ListView data without selecting

Hi, 

 

I have a listview which when you click on pops up into a sheet showing further details of the choosen item. On the sheet page, I have another ListView loading the data but this time, there is only one entry.

 

On this sheet page I would like to add an action on the navigation pane that will call on to a URL from the data. This URL is not displayed in the ListView.

 

The previous solutions I had are action bars triggered by selecting the individual list entry. So it was like this:

 

            onTriggered: {
                var page = Qt.webBrowserPage.createObject();
                var data = mainListComponent.ListItem.view.dataModel.data(mainListComponent.ListItem.indexPath);
                page.webURL = "http://en.wikipedia.org/wiki/" + data.wiki;
                page.pageTitle = "Wikipedia"
                Qt.rootNavPane.push(page);
            }

 This works OK.

 

However, when I try to use the same on my navigation bar, I get an error:

Result of expression 'mainListComponent.ListItem.view' [null] is not an object.

 So I guess is, how can I call on the same data from the list from my navigation bar without selecting it? 

 

Thanks!!

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Access ListView data without selecting

[ Edited ]

Just call data model function by model ID. You can not access mainListComponent outside of root container.

yourModelID.data(indexPathOfItem)

 

btw: Your onTriggered signal is from ListView? If is than i recommend you this access to item

Change this:

var data = mainListComponent.ListItem.view.dataModel.data(mainListComponent.ListItem.indexPath);

 to this

var data = dataModel.data(indexPath)

 onTriggered signal includes indexPath



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Access ListView data without selecting

Thanks for the tip! Didn't know I can call the data by the DataModel

 

What I did was I actually just defined a property string wURL, and add onto my ListView

 

onCreationComplete: { wURL = ListItem.data.wiki }

 Seems to work too.

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Access ListView data without selecting

And where you have 

onCreationComplete: { wURL = ListItem.data.wiki }

If is outside ListItemComponent you can't access the item by ListItem . To access currently selected item in ListView you can use selected() function from ListView, but you need to select item. Or you can access it like i wrote above

modelID.data(indexPathOfitem).wiki

 

 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Access ListView data without selecting

Does this mean that I can load the data into a DataModel and not use any ListView? And access the data from Datamodel directly?

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Access ListView data without selecting

You can access data of model item with ListItemData, but only inside the ListItemComponent not outside of listview



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Access ListView data without selecting

btw: now I see you access data like this

wURL = ListItem.data.wiki this is not correct.

Correct is

wURL = ListItemData.wiki



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog