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
Highlighted
Developer
Posts: 24
Registered: ‎02-09-2014
My Device: BlackBerry Z30
My Carrier: Telkom SA
Accepted Solution

Refresh a listView when a page is popped

Hi all,

I'm new in the cascades developing world. I'm trying to make a two pages app. the first page displays items in a listview and has a action buttom "new item" at the bottom. on triggered it pushes the second page which contains the fields for a new record. it has a save action button. when trigged in inserts the item in the data base and pops revealing the first page. My problem is that the new record is not displayed on the page. unless I close and reopen the app. I'm using an sql database to populate the list view. and I'm doing everything in cascades (no C++ back end)

Thanks in advance for your help.

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Refresh a listView when a page is popped

welcome to the support forums.

you have several options.

- insert the item in sql, then reload the whole listview. you could do that by listening to the onTopChanged signal of the navigation pane.

- inserting the item into the list resp. the data model (as well as in sql). this is a better solution in most cases, at least if the sorting is not done by sql or the like.
----------------------------------------------------------
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
Developer
Posts: 24
Registered: ‎02-09-2014
My Device: BlackBerry Z30
My Carrier: Telkom SA

Re: Refresh a listView when a page is popped

Thanks for the prompt answer. For the second option could you be more explicit. do I use myDataModel.insertList(data) ? is that what you mean?

what I do is after getting the new records details :
1. I query with sql statement (insert into table name etc)
2. reload with MyDataSource.load();
Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Refresh a listView when a page is popped

If you use a GroupDataModel you would just use insert(QObject*)
https://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html?f=group...

so you create the new item, write it in the database, insert it into the datamodel and then pop the page.
----------------------------------------------------------
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
Developer
Posts: 24
Registered: ‎02-09-2014
My Device: BlackBerry Z30
My Carrier: Telkom SA

Re: Refresh a listView when a page is popped

hi, thanks for your help. What worked is your first method (to listen to onTopChanged). Items populate very accurately. However when I load some pictures from the user's memory card it freezes a few micro seconds sometimes, and the scrolling as well is not that smooth. When all the pictures are from the phone's memory everything runs fast and smooth.  Is it a normal behaviour? (list items in the listView have texts and a picture)

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Refresh a listView when a page is popped

that is kind of a new question, isn't it? i suggest that you mark this thread as solved if it works and create a new one, one thread for one issue works the best usually.
----------------------------------------------------------
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
Developer
Posts: 24
Registered: ‎02-09-2014
My Device: BlackBerry Z30
My Carrier: Telkom SA

Re: Refresh a listView when a page is popped

OK cool.