10-29-2012 04:57 PM
If I add an ActionSet to a StandardListItem, then how do I find out which row (or indexPath) triggered an action?
10-29-2012 11:48 PM
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/document
10-30-2012 03:09 AM
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).
10-30-2012 11:24 AM
ooops my bad ![]()
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.doSomethi ngForContextAction(ListItemData.id)
}
}
}
}
] onTriggered: { var chosenItem = dataModel.data(indexPath); //do w/e here }
function doSomethingForContextAction(someId){
} }
10-30-2012 12:17 PM
Thanks, it looks clear. ![]()
How would this work in C, though?
10-30-2012 12:36 PM
i'll let you figure that one
given how awful the QDE is, i tried to avoid as much c++ as possible...
10-30-2012 06:20 PM
hehehe.
qde is not the best, but I have all my code in c++, so converting to qml is not optimal.