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
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Cannot sort list when button is pressed from System Dialog

I have a listview that uses a GroupDataModel with a JSON list, in a page. This page also has an Action Item called "Show Dialog". This Action Item has an attached object which is a SystemDialog. I followed this page: https://developer.blackberry.com/cascades/documentation/ui/dialogs_toasts/sysdialogs.html#pat1340376...

 

But I'm a bit stuck. It seems that I want the "Cancel" button to set the sorting keys and ascending = true and vice-versa for the "OK" button. I can't seem to do so. Here is the code I have: 

 

TabbedPane {
    id: mainTabPage
    showTabsOnActionBar: true
    Tab {
        title: qsTr("Items")
        NavigationPane {
            Page {
                id: itemTabNav
                Container {
                    id: itemsContainer
                    ListView {
                        id: itemList
                        dataModel: dataModel
                        listItemComponents: [
                            ListItemComponent {
                                type: "item"
                                StandardListItem {
                                    title: ListItemData.country
                                    status: ListItemData.population
                                    description: ListItemData.capital
                                }
                            }
                        ]

                        //onTriggered: {}
                    }
                    attachedObjects: [
                        GroupDataModel {
                            id: dataModel
                            sortingKeys: [
                                "serial"
                            ]
                            grouping: ItemGrouping.None
                            sortedAscending: true
                        },
                        DataSource {
                            id: dataSource
                            source: "items.json"
                            onDataLoaded: {
                                dataModel.insertList(data);
                            }
                        }
                    ]
                }

                //Actions Go Here
                actions: [
                    //-- define the actions for first tab here
                    ActionItem {
                        title: qsTr("Show Dialog")
                        attachedObjects: [
                            SystemDialog {
                                id: dialogbox
                                title: "Dialog"
                                onFinished: {
                                    if (dialogbox.result == "ConfirmButtonSelection") {
                                        dataModel.sortingKeys = ["serial"]
                                        dataModel.sortedAscending = true
                                    } if (dialogbox.result == "CancelButtonSelection") {
                                        dataModel.sortingKeys = ["serial"]
                                        dataModel.sortedAscending = false
                                    }
                                }
                            }
                        ]
                        onTriggered: {
                            dialogbox.show()
                        }
                    }
                ]
                onCreationCompleted: {
                    dataSource.load();
                }
            }
        }
    }
}

 

When I click the OK or the Cancel button, nothing seems to happen. The list stays sorted by "seria' with the ascending set to true...which is what I defined in the GroupDataModel. Any ideas why?

Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: Cannot sort list when button is pressed from System Dialog

[ Edited ]

Either there is a bug, or the documentation is wrong, or I'm not understanding this...on this page: https://developer.blackberry.com/cascades/documentation/ui/dialogs_toasts/sysdialogs.html

 

Go to the section: Creating a system dialog in QML and look at th QML code:

SystemDialog {
                     id: myQmlDialog
                     title: "Friendly Warning"
                     body: "Kakel can be habit-forming... "
                     onFinished:{
                         if (myQmlDialog.result == "CancelButtonSelection")
                             myQmlToast.show();
                     }  
                  }

 

The onFinished has an "if" statment., which when changed to (myQmlDialog.result == 3), works well. It doesn't seem to like the string value "CancelButtonSelection". (https://developer.blackberry.com/cascades/reference/bb__system__systemuiresult.html)

 

So is this an issue. Can a moderator please look at this and recommend the next course of action please?

 

Thanks

 

 

Please use plain text.