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
Contributor
Posts: 48
Registered: ‎11-03-2011
My Device: Playbook
My Carrier: None
Accepted Solution

Unable to access property variant from within contextActions(within StandardListItem)

Hi,

 

I want to pass the values of a listItem to a sheet using the context menu but I cannot access the property variant from within the action item.

 

I have a listview and within the listView I am using  StandardListItem.

 

Then within the StandardListItem I have defined my contextActions.

 

If I try to assign a value I receive the error: Error: Invalid write to global property "_contentView"

And if I try to use the property I receive the error: ReferenceError: Can't find variable: _contentView  

 

Here is the relevent section of my QML.

 

NavigationPane {
id: navMain
property variant _contentView

Page {
id: projectsListPage

Container {

ListView {
objectName: "projectsList"
id: projectsList

// The data model used defined in the attachedObjects for the list.
 dataModel: projectsModel

listItemComponents: [
ListItemComponent {
type: "item"
StandardListItem {

reserveImageSpace: false
title: {
ListItemData.name
}
contextActions: [
ActionSet {


 title: ListItemData.name 
ActionItem {
title: "View Details"
imageSource: "asset:///images/Edit.png"


onTriggered: {
var chosenItem = ListItemData;

  _contentView = chosenItem;
console.debug("test: "+_contentView.createDate);

projectDetailsClicked( _contentView)
//editProjectSheet.visible = true;
}

 

There are no problems accessing the property variant from the listview signals such as onSelectionChanged so why not within the actionItem? 

 

Your help is appreciated, Thx. 

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Unable to access property variant from within contextActions(within StandardListItem)

Just curiosity:
What happens if you use navMain._contentView?
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Contributor
Posts: 48
Registered: ‎11-03-2011
My Device: Playbook
My Carrier: None

Re: Unable to access property variant from within contextActions(within StandardListItem)

I get the following error:  ReferenceError: Can't find variable: navMain

 

 

Contributor
Posts: 48
Registered: ‎11-03-2011
My Device: Playbook
My Carrier: None

Re: Unable to access property variant from within contextActions(within StandardListItem)

Ok I am using the solution described here: http://supportforums.blackberry.com/t5/Cascades-Development/QML-Accessing-variables-defined-outside-...

But alas it is not the end of my issues Smiley Sad
Developer
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Unable to access property variant from within contextActions(within StandardListItem)

Hmm I just noticed this, I have this in my page's actionItem: 

 

ActionItem {
id: songs
ActionBar.placement: ActionBarPlacement.OnBar
title: "Songs"
onTriggered: {
contextProperty.breakString(_contentView.notes);
}
}

and that works fine, it passes the contentView to the function, does that mean that I am infact accessing it in the way you need? Or is this different.