View Single Post
Posts: 301 | Thanked: 531 times | Joined on Aug 2010 @ The Netherlands
#109
Thanks for helping, coderus!

The simplified code looks like this.

Code:
import QtQuick 2.0
import Sailfish.Silica 1.0
import "../scripts/Database.js" as Database

Page {
    id: thisWayptPage

    ListModel {
        id: listModelLett

        function updateLett()
        {
            listModelLett.clear();
            var lettrs = Database.getLettersWP(generic.wpId);
            for (var i = 0; i < lettrs.length; ++i) {
                listModelLett.append(lettrs[i]);
            }
        }
    }

    Component.onCompleted: listModelLett.updateLett();

    SilicaFlickable {

        PageHeader { ... }

        Column {

            TextArea { ... }

            Repeater {
                model: listModelLett

                ListItem {

                    Button {
                        text: letter + qsTr(". Click to change")
                        onClicked: {
                            pageStack.push(Qt.resolvedUrl("LetterPage.qml"),
                                           {"letterid": letterid})
                        }
                    }
                 }
            }
        }
    }
}
I took the ListModel from the app BudgetBook. The database function just reads the records from the table, in order to fill the ListModel.

On clicking the button, the Dialog in "LetterPage.qml" provides the possibility to enter a value for the letter. Then onDone, the value is stored in the database. After the pop() I don't know how to update the ListModel from the updated database.

This morning I thought of a work-around, but a proper method would be nice.
__________________
Palm Treo -> N900 -> N9 -> Jolla -> SailfishX -> XA2
Developer mode novice, and enjoying it
 

The Following User Says Thank You to rob_kouw For This Useful Post: