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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 24
Registered: ‎04-18-2014
My Device: z10
My Carrier: DTAC

Re: How to get CustomListItem in ListView ?

ListItemData is data of items in model
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get CustomListItem in ListView ?


AlexeyPanov wrote:
ListItemData is data of items in model

no. ListItemData is the currently selected item, for example in an ActionItem:

DeleteActionItem {
    onTriggered: {                                        
deleteItem(ListItemData); } }

 If you just want to do something on click (without an action) you use onTriggered which delivers the indexPath with it:

onTriggered: {
  var item = dataModel.data(indexPath);
  //do stuff with item
}

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 24
Registered: ‎04-18-2014
My Device: z10
My Carrier: DTAC

Re: How to get CustomListItem in ListView ?

So , what kind of type of ListItemData is then ?
here
DeleteActionItem {
onTriggered: {
deleteItem(ListItemData);
}
}
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get CustomListItem in ListView ?

the item that is selected when the action is triggered
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 24
Registered: ‎04-18-2014
My Device: z10
My Carrier: DTAC

Re: How to get CustomListItem in ListView ?

yes that i understand. but i need get SongItem object from ListView
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get CustomListItem in ListView ?

if you call the delete action while a SongItem object is selected ListItemData will be a SongItem object.

If you click on it onTriggered will be called with the indexPath of a SongItem object in the dataModel.
Calling dataModel.data with the indexPath will return the SongItem object.

In either way you will have the SongItem object. All good?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 24
Registered: ‎04-18-2014
My Device: z10
My Carrier: DTAC

Re: How to get CustomListItem in ListView ?

onTriggered: {
music_list.clearSelection();
select(indexPath);
var songItem = dataModel.data(indexPath);

look at what i do , but my songItem is var, i should casting to SongItem type ? but how i could do in QML ?
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get CustomListItem in ListView ?

javascript is untyped.

why do you call clearSelection followed by select?

in any case, songItem is of type SongItem, you can access its properties.
if you call songItem.label = "my new label" the label property (given it exists) will be set accordingly.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 24
Registered: ‎04-18-2014
My Device: z10
My Carrier: DTAC

Re: How to get CustomListItem in ListView ?


simon_hain wrote:

why do you call clearSelection followed by select?

l clear selection on all items at first, previous select clear, then i select current item which i touched on.

 


simon_hain wrote:

in any case, songItem is of type SongItem, you can access its properties.
if you call songItem.label = "my new label" the label property (given it exists) will be set accordingly.

what type is "label" property ?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get CustomListItem in ListView ?

as i do not know what properties your object has i just used an invented property (label). you should probably use one that really exists in your code...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter