3

Well I am just trying to get the value from the list-view on selection and pass it to the next screen(page). But I am unable to do as it shows error like

asset:///main.qml:25: TypeError: Result of expression 'dataModel.model' [undefined] is not a function.

My following piece of code is as follows

This code is of my main.qml

NavigationPane 
{
id:navi
Page 
{
    Container
    {
         background: Color.Transparent
         topMargin:2.0

         TextField {
             id: lb1
             text:""
         }

         ListView 
         {
            topMargin: 2.0
            dataModel: XmlDataModel { source: "model.xml" }
            onTriggered: {
                console.log("onTriggered");

                // Retrieve the selected item
                var selectedItem = dataModel.data(indexPath);
                    lb1.text = selectedItem.status;

                pushed.lb2.text="You Selected :" + lb1.text;
                navi.push(pushed)
                }

           }
         }

}

attachedObjects: [
    Page2 {
        id: pushed
        }
]

}   

This code is of my second page Page2.qml, where I want to retrieve the info from the main.qml

import bb.cascades 1.0

Page {
property alias lb2: lb2
Container {
    horizontalAlignment: HorizontalAlignment.Center

    Label {
        id:lb2
        horizontalAlignment: HorizontalAlignment.Center
        verticalAlignment: VerticalAlignment.Center
        text: "You Selected :" + lb1
    }

  }
}

I am new to this development.

j0k
  • 22,600
  • 28
  • 79
  • 90
avipandey
  • 57
  • 4

1 Answers1

0

You can get current item of the model on Trigger like as below code..

onTriggered: {
      var selectedItem = dataModel.data(indexPath);
      textField.text = selectedItem.status;
}

You can learn more from Responding to selection.

Updated:

You have to set Alias for pass data from one page to another page.

Some problem in your error..

1)Remove text in below line in OnTriggerd.

pushed.lb2 ="You Selected :" + lb1.text;

2) Set Alias properly

property alias lb2: lb2.text
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
  • 1
    I tried your code but the page is translating without showing the value. I have edited the code please have a look at this. – avipandey Sep 28 '13 at 06:05