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
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil
Accepted Solution

Remove items from ListView from a ContextAction in QML?

Is it possible to remove an list item in qml triggered from a context action? I have tried to do it in onTriggered signal of the ActionItem of the context actions set but it seems like I can't even access my ListView by its id.

Contributor
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Remove items from ListView from a ContextAction in QML?

[ Edited ]

I had the same problem. In my case, I only care about the depth, so I did this:

            onTriggered: {
                // item selection handler, write custom code here
                console.log("SELECTED path:" + indexPath)
                if(indexPath.length > 1) {
                        //Do something else
                } else {
                       navigationPane.pushLevel(indexPath)
                }
            }

 

Contributor
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Remove items from ListView from a ContextAction in QML?

And here is the complicated way:
"Using a Custom DataModel to Filter Data for a ListView" knowledge base article found here: http://supportforums.blackberry.com/t5/Cascades-Development-Knowledge/Using-a-Custom-DataModel-to-Fi...
Developer
Posts: 77
Registered: ‎05-21-2012
My Device: DA C, Z10 LE, Passport
My Carrier: TIM

Re: Remove items from ListView from a ContextAction in QML?

Inside a list component should be possible to remove it by

 

myItemRoot.ListItem.view.dataModel.removeAt( myItemRoot.ListItem.indexPath );

 Inside the OnTriggered could be:

 

listView.dataModel.removeAt( indexPath );