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: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: IDEA

How to update the previous page data in navigation pane on popping the current page ?

Hi!

 

     I am loading a qml file and from there I am pushing another screen. And selecting an option there, I want to update a property in the previous screen after poping the current screen. I tried loading the previious screen and setting the property there. on<Property>Changed: slot is recieving the assigned value, but not updating it in the UI. how to achieve it...!

 

Thanks in advance...!

- Raju
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to update the previous page data in navigation pane on popping the current page ?

In NavigationPane's onPopTransitionEnded handler you have the pointer to the page being popped. Before destroying it take the value from it and assign to a property on first page.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 141
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: How to update the previous page data in navigation pane on popping the current page ?

Hi,

 

     I tried like u said but it is also not effecting the property of a first qml file.If u have any sample on this please provide it.

 

Regards,

Naresh Kodumuri.

Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to update the previous page data in navigation pane on popping the current page ?

[ Edited ]

I've created a new project from QDE NavigationPane template and modified it to show how to return values from a page pushed to the Navigation Pane:

 

After replacing QML files with the ones I'm posting below, run the project then:

 

1. Click "Show detail" button

 

2. On the new page choose "Break" from the menu. testProperty will be set to "TEST".

 

3. Click "Back". Button text on main page will change to the value contained in testProperty on second page, in this case "TEST".

 

My modifications are marked with "//////////".

main.qml:

 

// Navigation pane project template
import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    Page {
        // page with a picture thumbnail
        Container {
            background: Color.Black
            layout: DockLayout {
            }
            Button {
                id: detailButton;
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center
                text: qsTr("Show detail")
                imageSource: "asset:///images/picture1thumb.png"
                onClicked: {
                    // show detail page when the button is clicked
                    var page = getSecondPage();
                    console.debug("pushing detail " + page)
                    navigationPane.push(page);
                }
                property Page secondPage
                function getSecondPage() {
                    if (! secondPage) {
                        secondPage = secondPageDefinition.createObject();
                    }
                    return secondPage;
                }
                attachedObjects: [
                    ComponentDefinition {
                        id: secondPageDefinition
                        source: "DetailsPage.qml"
                    }
                ]
            }
        }
    }
    onCreationCompleted: {
        // this slot is called when declarative scene is created
        // write post creation initialization here
        console.log("NavigationPane - onCreationCompleted()");

        // enable layout to adapt to the device rotation
        // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
        OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
    }

/////////////////////////////// ADD HANDLER: onPopTransitionEnded: { detailButton.text = page.testProperty; } }

 DetailsPage.qml:

 

// Navigation pane project template
import bb.cascades 1.0

Page {
    property string testProperty;   ///////////////////////////////// ADD PROPERTY

    // page with a picture detail
    id: pgDetail
    actions: [
        // create navigation panel actions here
        ActionItem {
            title: qsTr("Break")
            onTriggered: {
                imgView.imageSource = "asset:///images/picture1br.png"
                testProperty = "TEST";  /////////////////////////// SET VALUE
            }
        }
    ]
    paneProperties: NavigationPaneProperties {
        backButton: ActionItem {
            onTriggered: {
                // define what happens when back button is pressed here
                // in this case is closed the detail page
                navigationPane.pop()
            }
        }
    }
    Container {
        background: Color.Black
        Label {
            text: qsTr("Page 2")
            horizontalAlignment: HorizontalAlignment.Center
            textStyle {
                base: SystemDefaults.TextStyles.TitleText
                color: Color.Yellow
            }
        }
        ImageView {
            id: imgView
            imageSource: "asset:///images/picture1.png"
            horizontalAlignment: HorizontalAlignment.Center
        }
        Label {
            text: qsTr("Picture description")
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
}

 

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 141
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: How to update the previous page data in navigation pane on popping the current page ?

Hi,

   Thank u very much for ur reply.I am implementing the same concept using cpp.Today i solved the problem.

 

Thanks,

Naresh Kodumuri.