01-10-2013 07:23 PM
I have a problem with my contextmenu it seems like it can't access the contextproperty to call c++ functions or the indexPath of the selected List item
import bb.cascades 1.0
import com.remoteimage 1.0
import "global.js" as Global
Container {
layout: DockLayout {
}
ListView {
id: feedList
objectName: "feedList"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
layout: GridListLayout {
headerMode: ListHeaderMode.Standard
columnCount: 3
}
dataModel: XmlDataModel {
source: "feed.xml"
}
listItemComponents: [
ListItemComponent {
type: "header"
Header {
topMargin: 8
title: ListItemData.title
}
},
ListItemComponent {
type: "feed"
content: Container {
layout: DockLayout {
}
Container {
layout: StackLayout {
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
Container {
layout: DockLayout {
}
RemoteImageView {
url: Global.server_url + ListItemData.image
maxWidth: 250.0
maxHeight: 250.0
}
}
Container {
layout: DockLayout {
}
horizontalAlignment: HorizontalAlignment.Center
Label {
text: ListItemData.title
textStyle.textAlign: TextAlign.Center
horizontalAlignment: HorizontalAlignment.Center
}
}
contextActions: [
ActionSet {
actions: [
ActionItem {
title: "Delete"
imageSource: "asset:///images/delete.png"
onTriggered: {
var selectedItem = feedList.dataModel.data(indexPath);
_n3ws.requestDelete(selectedItem.id, selectedItem.custom);
}
}
]
}
]
}
}
}
]
onTriggered: {
var selectedItem = dataModel.data(indexPath);
_n3ws.requestRSS(selectedItem.feedlink);
navPaneFeed.push(articlesPage);
}
}
ActivityIndicator {
objectName: "feedIndicator"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
preferredWidth: 200
preferredHeight: 200
onStopped: {
}
}
onCreationCompleted: {
controlDelegateArticles.delegateActive = true
}
} Any help would be nice ![]()
01-10-2013 08:26 PM - edited 01-10-2013 08:27 PM
I actually did something similar in my app.
I had my context menu attached directly to the ListView. It does not give you the index path automatically but you can obtain it by using the listviewid.selected () method
My code is similar to this:
contextActions: [
ActionSet {
title: "Context Menu"
actions: [
DeleteActionItem {
onTriggered: {
var indexPath = idOfTheListView.selected ();
//do stuff with index path (I used it to delete that item)
}
}
] //end actions
} //end action set
]} //end listview
You can also use a DeleteActionItem to get the standard RIM delete icon. It also places the delete context item on the bottom of the context menu.
Let me know if that helps.