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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Contributor
A7omic
Posts: 48
Registered: ‎11-03-2011
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. 

Please use plain text.
Developer
soaman
Posts: 610
Registered: ‎03-03-2011
My Carrier: Mobitel

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

Just curiosity:
What happens if you use navMain._contentView?
--------------------------------------------------------

Follow our developer blog on Slovenia BlackBerry Developer Group!
Please use plain text.
Contributor
A7omic
Posts: 48
Registered: ‎11-03-2011
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

 

 

Please use plain text.
Contributor
A7omic
Posts: 48
Registered: ‎11-03-2011
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 :smileysad:
Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
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.

Please use plain text.