locked
How to reorder data in WinJS.Binding.List datasource to use it from listview to flip view?

    Question

  •   I'm loading data in a listview on the first page. When a user clicks an item from that grid layout, I take them to itemdetail page, where they can then browse each item through flip view. I'm binding same datasource to flipview, but I need to reorder items. This datasource for flipview should start from item invoked (and not from the first item in the datasource). How do I do that? I'm trying all day long to use splice and slice and everything. But no result. My data is stored in json array of objects.

    Thanks for looking.

    Friday, May 17, 2013 6:34 AM

Answers

  • Hi,

    I am assuming that your data is array of data.

    When you navigate from the MainPage to DetailsPage on the itemInvoked method, pass the index also.

    MainPage

    itemInvoked: function (args) {

    var index = args.detail.itemIndex; WinJS.Navigation.Navigate("<Path for the detail page>",

    { indexCurrent : index, data : <pass the data list/array> });

    },

    In the detail page ready event, assign the datasource and set the current page property to the index that was passed.

    DetailsPage

    ready: function(element,options) { var flipView = document.getElementById("flipView").winControl;

    var data = options.data;

    var list = new WinJS.Binding.List(data);

    var sortedList = list.createSorted(<function for sort>);

    flipView.itemDatasource = sortedList.dataSource;

    flipView.currentPage = options.indexCurrent; // Set to what you have passed. },


    For ordering the list data and the sorting function, you can have a look at this link.

    - Girija





    Friday, May 17, 2013 10:02 PM

All replies

  • Hi,

    I am assuming that your data is array of data.

    When you navigate from the MainPage to DetailsPage on the itemInvoked method, pass the index also.

    MainPage

    itemInvoked: function (args) {

    var index = args.detail.itemIndex; WinJS.Navigation.Navigate("<Path for the detail page>",

    { indexCurrent : index, data : <pass the data list/array> });

    },

    In the detail page ready event, assign the datasource and set the current page property to the index that was passed.

    DetailsPage

    ready: function(element,options) { var flipView = document.getElementById("flipView").winControl;

    var data = options.data;

    var list = new WinJS.Binding.List(data);

    var sortedList = list.createSorted(<function for sort>);

    flipView.itemDatasource = sortedList.dataSource;

    flipView.currentPage = options.indexCurrent; // Set to what you have passed. },


    For ordering the list data and the sorting function, you can have a look at this link.

    - Girija





    Friday, May 17, 2013 10:02 PM
  •   Thanks Girija.
    Monday, May 20, 2013 7:45 PM