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
Robdob
Posts: 225
Registered: ‎01-31-2013
My Device: Developer

Whats the best way to scroll through detail records linked to a listview,arraydatamodel?

Hi,

 

I have a listview and in the onTrigered signal handler I launch a detailpage passing it some info from the datamodel attached to the listview.   What I would like to do is allow the user to scroll to the next and prev record in the datamodel from within the detailpage being displayed.  currently the user needs to close the detailpage, and then select the next record of interest from within the listview which then once again sends the onTriggered() signal to the lisview which reopens the next detailpage..

 

Can someone suggest the best approach for handling this?

 

my current qml looks something like this:

 

Page {
       content: Container {
        layout: StackLayout {

        }
           Container {
            ListView {
                   id: searchListView
                dataModel: searchDataModel
                listItemComponents: [
                    ListItemComponent {
                        type: ""
                        SearchResultsListItem {
                            title: ListItemData.Title
                        }
                    }
                ]
                onTriggered: {
                    var feedItem = searchDataModel.data(indexPath);
                    var pagesecondPage = secondPage.createObject();
                    pagesecondPage.lblSearchAdViewHeader.text = feedItem.Title;
                    firstPage.parent.push(pagesecondPage);
                }

            }
        }

    }
    attachedObjects: [
        ComponentDefinition {
            id: secondPage

            Page {
                property alias lblSearchAdViewHeader: lblSearchAdViewHeader

                actions: [
                    ActionItem {
                        id: aiDisplayPrevAd
                        title: qsTr("Prev Ad")
                        
                        onTriggered: {
                            // This is where I would like to display the prev
                            // record in the listview
                            
                        }
                    },
                    ActionItem {
                        id: aiDisplayNextAd
                        title: qsTr("Next Ad")
                        
                        onTriggered: {
                            // This is where I would like to display the Next
                            // record in the listview
                            
                        }
                    }
                ]

                Container {
                         Label {
                            id: lblSearchAdViewHeader
                            text: "HEADER"
                         }
                }
            }
        },
        ArrayDataModel {
            id: searchDataModel
        },
        DataSource {
            id: searchDataSource
            type: DataSourceType.Json
            onDataLoaded: {
                //....
            }
            onError: {
                // .....
            }
        }
    ]
    
}

 

 

thanks,



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!
Please use plain text.
Developer
simon_hain
Posts: 16,042
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Whats the best way to scroll through detail records linked to a listview,arraydatamodel?

you could use the indexPath to load the next item into your detail view
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Robdob
Posts: 225
Registered: ‎01-31-2013
My Device: Developer

Re: Whats the best way to scroll through detail records linked to a listview,arraydatamodel?

Hi,

 

thanks, but from where? from within the ActionItem?



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!
Please use plain text.
Developer
simon_hain
Posts: 16,042
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Whats the best way to scroll through detail records linked to a listview,arraydatamodel?

yes, that would be one option.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Robdob
Posts: 225
Registered: ‎01-31-2013
My Device: Developer

Re: Whats the best way to scroll through detail records linked to a listview,arraydatamodel?

could you give me a sniplet or something...  how do I keep track of where I am in the listview,  also update the the listvew with the new postion ect.  i.e. is there an easy way to increase of decrease the current value of the indexPath by one?

 

thanks,



GeoYeo - Free Local classifieds - Built for Blackberry 10, if you like it please Rate It and Share it!
Please use plain text.