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
Developer
Posts: 73
Registered: ‎04-08-2014
My Device: Z10
My Carrier: XL
Accepted Solution

onTriggered to Detail Info (LISTVIEW)

Hi

sorry for asking again

i want to show the detail of my promo

 this is my main QML

NavigationPane {
           id : nav1
           onPopTransitionEnded: page.destroy()
        Page {
            
            Container {
                Header{
                    title: "Promo"
                } 
                
                ListView {
                    id: listViewDemo
                    dataModel: GroupDataModel {
                        id : prm1
                        grouping: ItemGrouping.None
                    }
                    listItemComponents: [
                        ListItemComponent {
                            type: "promo"
                            Container {
                                layout: StackLayout {
                                    orientation: LayoutOrientation.LeftToRight
                                }
                                WebView {
                                    preferredWidth: 150
                                    preferredHeight: 90
                                    verticalAlignment: VerticalAlignment.Top
                                    url : ListItemData["ImageLink"]
                                
                                }
                                StandardListItem {
                                    title: ListItemData["promoID"] + "." + ListItemData["Title"] 
                                    description: ListItemData["Description"]
                                    leftMargin: 30
                                    verticalAlignment: VerticalAlignment.Center  
                                       
                                    }
                                   
                             }  
                          }   
                    ]  
                        
                    function itemType(data, indexPath) {
                        return "promo";
                }
            
                onTriggered: {
                    if(indexPath!=0){
                        var promo = prm1.data(indexPath);
                        var promodetail = promocontent.createObject();
                        promodetail.promo = promo;
                        nav1.push(promocontent);
                    }
                }
                }
                }
             }
         }
           
            attachedObjects: [
                DataSource {
                    id: serviceDataSource
                    source:                                  "http://www.rws.rajaspot.com/rs_promoclient.php"
                    type: DataSourceType.Json
                    onDataLoaded: {
                    listViewDemo.dataModel.insertList(data.promo_info)
                    }
                },
                ComponentDefinition {
                    id : promocontent
                    source : "PromoContent.qml"
                }
            ]
            
            onCreationCompleted: {
                serviceDataSource.load();
            }

 this is my promodetail

Page {
    property variant promo;
    Container {
        
        id: container1
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center
        topPadding: 50
        WebView {
            
            id : imageview
            horizontalAlignment: HorizontalAlignment.Center
            url: promo["ImageLink"]
            preferredWidth: 400
            preferredHeight: 400
        }
        Label {
            
            id:label1
            textStyle.base: SystemDefaults.TextStyles.BigText
            horizontalAlignment: HorizontalAlignment.Center
            text:promo["Title"]
        }
        Label {
            id:label2
            textStyle.base: SystemDefaults.TextStyles.SubtitleText
            horizontalAlignment: HorizontalAlignment.Center
            text:promo["Description"]
        }    
    }
}

 the following error are

url: promo["ImageLink"]

 

text:promo["Title"]

 

text:promo["Description"]

 it can't call from my main.qml

any suggestion?

thanks

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: onTriggered to Detail Info (LISTVIEW)

have you tried inside your onTriggered() if promo really has these properties your're using in your pushed Page ?

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: onTriggered to Detail Info (LISTVIEW)

[ Edited ]

As ekke says check if your promo properties exists

onTriggered: {
    clearSelection() // optional
    select(indexPath) // optional
    var item = dataModel.data(indexPath)
    if (item){
        // check if your properties exists
        console.log(item.Description)
        var promodetail = promocontent.createObject();
        promodetail.promo = promo;
        activePane.push(promodetail)
    }
}

 also be sure if in your promodetail page is actually assigned the promo property. You can check it in the signal

onPromoChanged:{
    if (promo){
        // Now you can manipulate with them
    }
}

 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 73
Registered: ‎04-08-2014
My Device: Z10
My Carrier: XL

Re: onTriggered to Detail Info (LISTVIEW)

@Ekke : thanks ekke, I already try and it has a property on it, like u said

@Benecore :

so sorry benecore

 on this line u say that //you can manipulate with them

if (promo){
        // Now you can manipulate with them
    }

 

can u give the example of that? 

many-many thanks to you

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: onTriggered to Detail Info (LISTVIEW)

[ Edited ]

In some cases your promo property can be 'undefined' after you push the page. Because isn't yet assigned. You can avoid this if you check the property on your page.
For example:

Page{
    property variant promo: null

    Container{
        layout: DockLayout{}
        leftPadding: 20
        rightPadding: 20
        topPadding: 20

        Label{
            id: label
            horizontalAligment: HorizontalAligment.Center
            /* In some cases will be the text empty. Because promo property is not yet assigned*/
            text: promo.Description
        }
    }
}

 

-------------------------------------------------
Check the simple example. You have two options to avoid 'undefined' promo property.
1. Replace the text property in label with this
text: promo ? promo.Description : ""
2. Set the label from promo property signal
onPromoChanged: if(promo) label.text = promo.Description

My English is bad so i hope you understand what i mean. Maybe someone with good English can specify my 'answer' Smiley Very Happy

 

EDIT:

Also you can find 'Passing data between pages QML' for more info



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 73
Registered: ‎04-08-2014
My Device: Z10
My Carrier: XL

Re: onTriggered to Detail Info (LISTVIEW)

[ Edited ]

I already change the label as you said and also try the different one to put onItemChanged in my code,

but stil the promodetail is nothing show up

whats wrong ya? hmm...

 

thanks for helping benecore

 

note : my english is so bad too 

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: onTriggered to Detail Info (LISTVIEW)

not onItemChanged but onPromoChanged in your case.

 

Anyway here is a working example. Play with it and check what you doing wrong

https://www.dropbox.com/s/y89a6hm5isaznsh/promotest.zip

Hope it helps



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Highlighted
Developer
Posts: 73
Registered: ‎04-08-2014
My Device: Z10
My Carrier: XL

Re: onTriggered to Detail Info (LISTVIEW)

Thank u so much benecore, u're so kind

sorry for bother u 

u really save my life HAHA

 

cheers

 

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: onTriggered to Detail Info (LISTVIEW)

You're welcome. I'm glad i helped. Anytime Smiley Wink



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 38
Registered: ‎11-24-2015
My Device: z10
My Carrier: airtel

Re: onTriggered to Detail Info (LISTVIEW)

link not working please add working link