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
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Refresh ListView?

Hi,

 

Is there any way to refresh my ListView within QML?

 

I use a SQL data model that loads data asynchronously into the list (its the "Quotes" sample, modified).

 

Thanks.

My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: Refresh ListView?

Never used SQL data but in my ListView with xml data I do:

 

DataSource {
id: myDataSource

}

...

ActionItem {

onTriggered: {
myDataSource.clear();
myDataSource.load();
    }
}

 

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Re: Refresh ListView?

Thanks for the reply. Will give it a try and let you know...
My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!
Developer
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Re: Refresh ListView?

The

 

myDataSource.clear();

 

is not working- nothing happens. But when comment it out and leave only the

 

myDataSource.load();

 

it works, but not as expected- the list items doubles, then triples, and so on. I think the data is loaded on top of the remaining data...

 

Any ideas?

 

My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!
New Developer
setiawand
Posts: 41
Registered: ‎07-12-2012
My Device: Orlando, Dev Alpha

Re: Refresh ListView?

have you tried the latest quotes example or weatherguesser ?

Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: Refresh ListView?

[ Edited ]

Try this:

 

 GroupDataModel {
            id: myDataModel
...
        },

DataSource { id: myDataSource ... onDataLoaded: { myDataModel.clear(); myDataModel.insertList(data) } } ... ActionItem { onTriggered: { myDataSource.load(); } }

 

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Re: Refresh ListView?

I've based my project off the latest Quotes sample and it doesn't refresh the list anywhere.
My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!
Developer
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Re: Refresh ListView?

The app crashes when it comes to myDataSource.load()...?
My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: Refresh ListView?

You that that ActionItem inside of actions: [ ] right?

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Roshnal
Posts: 104
Registered: ‎04-15-2012
My Device: BlackBerry PlayBook with OS 2.0

Re: Refresh ListView?

Yeah, that ActionItem inside actions: [ ] calls a function. It then updates the database and then have to load the data again.
My BlackBerry 10 apps: Roshnal Lihinikadu
Lots more coming up!