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: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone
Accepted Solution

ListView not populating when entered second time

Hi all,

 

This is my previous Query :

 http://supportforums.blackberry.com/t5/Cascades-Development/problem-with-findChild/m-p/2441175#M2524...

 

Now while opening the app i can see the listview in the note.qml and after clicking back from navigation pane and entering the same page(note.qml) again i am not able to see the ListView.

 

The code is available in the above link.

 

 

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: ListView not populating when entered second time

Hi all,

 

Please have a look at the issue. I cant figure this out yet... Hope some one can help me

 

The ListView inside the note.qml is not poulating when entered second time. Ii is opening the note.qml page and i can see the actionitem associates with this page but not the ListView

 

 

Below is my main.qml

import bb.cascades 1.0

TabbedPane {
    showTabsOnActionBar: true
    objectName: "objectCrypt"
    Tab {
        title: qsTr("Private")
        imageSource: "asset:///actionbar/private.png"
        NavigationPane {
            id:navPane
           .
           .
           .
           .
           ImageButton {
                id: noteicon
                defaultImageSource: "asset:///images/noteicondef.png"
                pressedImageSource: "asset:///images/noteiconpre.png"
                disabledImageSource: "asset:///images/noteicondis.png"
                layoutProperties: AbsoluteLayoutProperties {
                    positionX: 347.0
                    positionY: 580.0
                }
                scaleX: 2.0
                scaleY: 2.0
                onClicked: {
                    var np = notePage.createObject();
                    navPane.push(np);
                    Qt.objectCrypt.fetchNotes();
                }
           }
           .
           .
           .
           .
     attachedObjects: [
        ComponentDefinition {
            id: notePage
            source: "note.qml"
        }
      ]

 

 

This is my note.qml

import bb.cascades 1.0
import bb.data 1.0

Page {
    resizeBehavior: PageResizeBehavior.None
    Container {
        background:bg.imagePaint
        layout: AbsoluteLayout {}
          ListView {
            id:notelistview
            objectName: "notelistview"
            layoutProperties: AbsoluteLayoutProperties {
                positionX: 0.0
                positionY: 129.0
            }
            opacity: 0.9
            dataModel: groupDataModel
            listItemComponents: [
                ListItemComponent {
                    id:row
                    type: "item"
                    .
                    .
                    .
                    .
                }
             ]
                    .
                    .
                    .
                    .
}
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: ListView not populating when entered second time

What about the data model?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 19
Registered: ‎07-02-2013
My Device: BlackBerry Q10
My Carrier: Telus

Re: ListView not populating when entered second time

I am assuming groupDataModel is exposed via C++ right? Is Qt.objectCrypt.fetchNotes() the one that is populating the data model?

I believe your problem might be that the ListView is taking ownership of the "groupDataModel". Then it is destroying it once the page is destroyed. And the second time, it is not showing up because the data model was already destroyed.

See the ListView documentation, as soon as you assign it a dataModel it takes ownership if the datamodel does not have a previous parent. So your solution might here be to give the groupDataModel an existing parent so ListView doesn't try to take ownership.
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: ListView not populating when entered second time

Thanks @canadainc, i have done as you said.... its working perfectly now.

Thanks @zezke.