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
Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Load data into a ListView in a page and push the page into a NavigationPane?

[ Edited ]

Hello,

 

Just wondering if anyone found a way to dynamically load data into a List View in a Page (separate QML file), and push that page into a NavigationPane?

 

My navigation pane contains a page that has a list view. Clicking on that list view item will opens another page. That page contains another list view that I would like to load data into dynamically.

 

I find that upon pushing the new page into the Navigation Pane, it loads the page, but the ListView doesn't contain any data.

 

 

This is how I load the data into the list view:

 

QVariantList sqlData = mQuotesDbHelper->getRandomRecipes("quotes");

    if (!sqlData.isEmpty()) {
        mDataModel = categoryPane->findChild<GroupDataModel*>("randomModel");
        mDataModel->insertList(sqlData);
        mDataModel->setGrouping(ItemGrouping::None);
        mListView = categoryPane->findChild<ListView*>("randomList");
    }

 

And then: I tried to push the page using both:

 

var page = nav.deprecatedPushQmlByString("category.qml");    

nav.push(page)

 

and by pushing a page pointer into navigation pane:

 

nav.push(app.loadCategoryScene())

 

 

Thank you!

Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Load data into a ListView in a page and push the page into a NavigationPane?

I think deprecatedPush was indeed depricated.

I have done similar things with the lists - you can seach for my positing on the forums for various steps and hurdles that one might encounter.

All in all, in short, you can use something link

1. Have the second page with the listview as an attachedObject of the main navigation pane.

2. in the c++ code, get the refrence to the list you want to update

3. regarding pushing the list on the screen - i think the easiest would be from qml navigationPance.push(listScreenID) , and then you can register a slot on which the loading can take place - lazy loading ..... or since you have the reference, based on the onTriggered () - of your main list - you can proceed with the regular flow of your application
Developer
Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: Load data into a ListView in a page and push the page into a NavigationPane?

[ Edited ]

Thanks rock_win. your suggestion works well.

I find that to dynamically load data, I have to do the following, but I am not sure if that's the right or wrong way. Please let me know what do you think about this.

    QVariantList categoryData = mQuotesDbHelper->getQuotes("quotes");

    if (!categoryData.isEmpty()) {
        groupModel->clear();
        groupModel->insertList(categoryData);
        groupModel->setGrouping(ItemGrouping::None);
    }
    listView->resetDataModel();
    listView->setDataModel(groupModel);