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
Contributor
raysonyeung
Posts: 21
Registered: ‎02-07-2013
My Device: Z10
My Carrier: Company
Accepted Solution

ListView with InvokeActionItem

Hi everyone, I am trying to create a listview including an invokeactionitem to share something.

However, I found that the query of invokeactionitem is not accurate. Does anyone have any idea?

 

Here is my simplified coding.

 

ListView{

    dataModel: myDataModel // datamodel created by c++ coding

    ListItemComponents:[

        ListItemComponent{

            Container{

                Label{

                    text: ListItemData.content

                }

                contextActions:[

                   ActionSet{
                      InvokeActionItem{
                          query{
                               mimeType: "text/plain"
                               data: ListItemData.content // Data not always as same as the one that I want to share
                               invokeActionId: "bb.action.SHARE"
                           }
                       }
                   }
               ]

            }

        }

    ]

    onCreationCompleted:{

        myDataModel.loadData(); // loadData is a function to insert item to the datamodel

    }

}

Please use plain text.
Developer
shahumang8
Posts: 641
Registered: ‎08-09-2010
My Device: Not Specified

Re: ListView with InvokeActionItem

Hi Rasonyeung,

 

     Please check below link.

 

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

 

  

     I hope you got your solution if any doubt post me i help you .

 

     

-------------------------------------------------------------------------------

 

feel free to press the like button on the right side to thank the user that helped you.

Please use plain text.
Contributor
raysonyeung
Posts: 21
Registered: ‎02-07-2013
My Device: Z10
My Carrier: Company

Re: ListView with InvokeActionItem

I already read this post before.

 

The InvokeActionItem should be related the the ListItemComponent rather than the list view selection since it is belongs to it.

There is no selection signaling while you call the contextActions.

 

So, what you thing that is related in the post. We can discuss in it.

 

Thanks.

Please use plain text.
Contributor
raysonyeung
Posts: 21
Registered: ‎02-07-2013
My Device: Z10
My Carrier: Company

Re: ListView with InvokeActionItem

[ Edited ]

I already found a solution.

InvokeActionItem is created after the ListItemComponent created. Thus the query may get different data from the ListItem.

For example, the ListView is creating #21 ListItem. But the InvokeActionItem of #19 ListItem is just started to be created. Finally it will get a wrong data from the ListItemData.

 

Instead of using InvokeActionItem, directly using ActionItem is much better since the created period of the ActionItem is as same as the ListItem. so the ActionItem can always get the current ListItemData.

 

Here is the coding that I am currently using and it always return correct value to my InvokeQuery.

 

http://supportforums.blackberry.com/t5/Cascades-Development/Dynamic-InvokeQuery/m-p/2084381#M10730

 

 

ListView{

    dataModel: myDataModel // datamodel created by c++ coding

    ListItemComponents:[

        ListItemComponent{

            Container{

                Label{

                    text: ListItemData.content

                }

                contextActions:[

                   ActionSet{
                      ActionItem{

                          title: qsTr( "Share" )

                          onTriggered:{
                               query.mimeType= "text/plain"
                               query.data&colon= ListItemData.content // Data not always as same as the one that I want to share
                               query.updateQuery();
                           }

                           attachedObjects:[

                               Invocation{

                                   id: invoker

                                   query: InvokeQuery{ // QML editor show here has error, but it is correct coding

                                       id: query

                                       // Here must be empty and not a complete query, otherwise the onArmed function will be signaled once the object is created.

                                   }

                                   onArmed:{

                                       trigger("bb.action.SHARE");

                                   }

                               }

                           ]
                       }
                   }
               ]

            }

        }

    ]

    onCreationCompleted:{

        myDataModel.loadData(); // loadData is a function to insert item to the datamodel

    }

}

Please use plain text.