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
Highlighted
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi
Accepted Solution

Modify to entryComponent.ListItem.indexPath?

[ Edited ]

Is it possible to modify this to get the currently selected index from within the context action?

 

Something like 

 

entryComponent.ListItem.indexPath

 

 

 

 

 

Subject Title edited to reflect new topic.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

[ Edited ]

@Philipk You've been on these forums long enough to know better, please avoid adding a new question to old solved threads. Create your own thread and either reference or link to the old information.

 

I've asked a mod to split this thread at your posting.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

Now the thread has been split, if you are asking how to access the selcted items then yes this can be done through the view.

 

    entryComponant.ListItem.view.selectionList()


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

Fuller example...

 

ActionItem {
    title: qsTr("Copy")
    imageSource: "asset:///images/actions/copy.png"
    
    onTriggered: {
        folderItem.ListItem.view.select(folderItem.ListItem.indexPath);
        var copied = folderItem.ListItem.view.dataModel.copyFolders(folderItem.ListItem.view.selectionList());
    }
}

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Modify to entryComponent.ListItem.indexPath?

[ Edited ]
entryComponant.ListItem.indexPath


returns the following

Error: Accessing ListItem.indexPath on a node that is not the root node in a list item visual. Try prefixing with the id of the item visual root node.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

[ Edited ]

Obviously the entryComponant should be replaced with the id of your item, as in my second example where it was folderItem.

 

ListItemComponent {

    type: "item"

    StandardListItem {

        id: folderItem

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Modify to entryComponent.ListItem.indexPath?

[ Edited ]

This is how my ListItem is set up

ListItemComponent {
id: entryComponant
content: EntryContainer {
// Also tried putting id here
isHighlighted: ListItem.active || ListItem.selected
}
}

 

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

[ Edited ]

The set up is correct as long as isHighlighted is a property in EntryComponant.

 

However at the time the ListView is populating you won't have any selected ListItems so I'm not sure what you are trying to achieve there?

 

Post your EntryComponant and ListView code, using the Code insert button (the clipboard with a C in it), if you can.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Modify to entryComponent.ListItem.indexPath?

import bb.cascades 1.0
import org.labsquare 1.0

Container {
    id: postContainer
    property bool isCreated
    property bool isHighlighted

    topPadding: Qt.defaultPadding
    bottomPadding: Qt.defaultPadding
    leftPadding: Qt.defaultPadding
    rightPadding: Qt.defaultPadding

    Container {

        topPadding: Qt.borderWidth
        bottomPadding: Qt.borderWidth
        leftPadding: Qt.borderWidth
        rightPadding: Qt.borderWidth

        background: isHighlighted ? Qt.themeColor : Color.create("#eeeeee")

        layout: DockLayout {

        }

        WebImageView {
            id: img
            url: ListItemData.thumbnail
            scalingMethod: ScalingMethod.AspectFill
            preferredWidth: Qt.DeviceInfo.width
            preferredHeight: 326
            visible: img.loading == 1.0
            loadEffect: ImageViewLoadEffect.Subtle
            opacity: 1
        }

        onCreationCompleted: {
            isCreated = true
        }
    }
}

 

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Modify to entryComponent.ListItem.indexPath?

This looks okay. Not sure how efficient a WebView would be in each ListItem though Smiley Happy you may like to look at asynchronous and caching later on.

 

Please show the code where you are trying to access the selecteditems as indicated in the example I gave.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.