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

BlackBerry® World™ 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
Highlighted
New Contributor
Posts: 8
Registered: ‎12-18-2012
My Device: BB 10
My Carrier: Mobilicity

Help with saving to XML file opend in a list.

Hi,

 

I created a list based on a XML file.

for each list item there are 3 radio buttons to select.

I want to save the radio button selection back into the xml file as a child of the current list item  ie:< ListItem ......... child="rediobuton selection" />

here is my code:

Plz help.

import bb.cascades 1.0

Page {
     actions: [
                // create navigation panel actions here
                ActionItem {
                    title: qsTr("Create a report")
                    onTriggered: {
                        imgView.imageSource = "asset:///images/picture1br.png"
                    }
                }
            ]
    Container {
        // the childcount for the list item
        property alias listChildCount: chList.childCount
        property alias radioIndex: radioGp.selectedIndex
        property alias currentListPostion: chList.ListItemData.title 
    
       ListView {
           id: chList
                   dataModel: XmlDataModel {
                       source: "models/Chapter2.xml"
                   }
         
                   listItemComponents: [
                       ListItemComponent {
                           type: "header"
                           Header {
                               title: ListItemData.title
                       }
                       },
                       ListItemComponent {
                           type: "listItem"
                       Container {
                        layout: DockLayout {}

                        // RadioGroup
                        // This is a reset function for the component RadioGroup. If called, it removes any
                        // selected RadioOption.
                        function resetSelectedOption() {
                            radioGp.resetSelectedIndex();
                        }

                        // This function allows selecting a specific index in the RadioGroup.
                        function setSelectedIndex(index) {
                            radioGp.setSelectedIndex(radioIndex);
                        }
                        RadioGroup {
                            id: radioGp
                            dividersVisible: false
                            preferredWidth: 150
                            minWidth: 149.0
                            Option {
                                id: option1
                                text: "H"
                                //     value: text
                            }
                            Option {
                                id: option2
                                text: "M"
                                //      value: text
                            }
                            Option {
                                id: option3
                                text: "L"
                                //        value: text
                            }
                            // When a new option is selected, we print the selection to the console.
                            onSelectedValueChanged: {
                                console.debug("New filling set: " + selectedValue);
                                if(selectedIndex >= 0) {
                                radioIndex = radioGp.selectedIndex
                                currentListPostion = chList.XmlDataModel.Data();
                                chList.XmlDataAccess.save(currentListPostion+1+"radioValue="&radioIndex, "..asset:///models/Chapter2.qml" )
                            }//endif
                            }
                        }
                        Divider {} // at the end of each list item
                        LabelLabel {
                            text: ListItemData.title
                            bottomPadding: 50.0
                            leftPadding: 150.0
                        }// end of LabelLabel
                        
                    } // end of Container
                } // end of second ListItemComponent
            ] // end of listItemComponents list
        } // end of ListView
    }
}