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
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

ActionSet in ListView

If I add an ActionSet to a StandardListItem, then how do I find out which row (or indexPath) triggered an action?

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: ActionSet in ListView

use the onTriggered event of the listview:

 

ListView {
 ...
 dataModel: ...

 listItemComponents: ...

 onTriggered: {
   var chosenItem = dataModel.data(indexPath);
   //do w/e here
 }

}

 

Also please check the docs, it's properly explained over there:

https://developer.blackberry.com/cascades/documentation/ui/lists/list_view_selection.html

Please use plain text.
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: ActionSet in ListView

This is the way you handle list item selection. But how to do this for an ActionItem? As far as I know, there is no such thing as a global indexPath for this (in C).

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: ActionSet in ListView

ooops my bad :smileyhappy:

 

this one is a little bit more complicated, and the documentation is indeed lacking on that part, here goes:

1) make sure your row data have some sort of unique identifier (id in this case)

2) add a function to handle your context action menu at the same level as your ListView (see doSomethingWithContextAction below)

3) from your ListItemComponent, access your listView, then call the function in step (2) by passing as argument your unique id

 

 

ListView {
 ...
 dataModel: ...

 listItemComponents: [
ListItemComponent {
Container {
id: listItemComponentContainer //this is required!
...ActionItem {
onTriggered: {
listItemComponentContainer.ListItem.view.doSomethingForContextAction(ListItemData.id)

}
}
}
}
] onTriggered: { var chosenItem = dataModel.data(indexPath); //do w/e here }

function doSomethingForContextAction(someId){
} }
Please use plain text.
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: ActionSet in ListView

Thanks, it looks clear. :smileyhappy:

How would this work in C, though?

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: ActionSet in ListView

i'll let you figure that one :smileyhappy: 

 

given how awful the QDE is, i tried to avoid as much c++ as possible...

Please use plain text.
Trusted Contributor
marcelnijman
Posts: 118
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C

Re: ActionSet in ListView

hehehe.

 

qde is not the best, but I have all my code in c++, so converting to qml is not optimal.

Please use plain text.