locked
Refreshing listview data when navigated too

    Question

  • I have a page containing a listView. The listviews data source loads a different set of values depending on where its nacigated to from.

    Think, User page, which loads different users data depending what username is clicked on.

    This works fine for the first user navigated to, but after that when you navigate to it the datasource does not reload the data and it shows the first users data still.

    How can I force the listview to reload its datasource on navigation to this page?

    Friday, December 06, 2013 7:16 PM

Answers

  • It appears that you need to set the datasource in JavaScript (vs. declarative markup). I'm not sure if you're using the VS Grid/Split/Hub templates (and the data.js file) or the standard page navigation model (navigator.js), but in any case you need to set .itemDataSource on the ListView element when you load the page, preferably in the predefined init() or ready() function. Like this:

         this.listViewElement.itemDataSource = this._datasourceItems.dataSource;

    If you aren't already passing info about the selected item in the navigate() call, then you might check out the VS templates for examples of how to do that. Here is one way to call navigate:

        var item = [itemObj.group.key, itemObj.title, itemObj.backgroundImage];

        nav.navigate("/pages/item/item.html", { item: item });

       



    Friday, December 06, 2013 10:19 PM