ListView virtualisation with IListDataAdapter RRS feed

  • Question

  • I get data from a service that have paged data, with a given page size of 15 items. It means I could query page 1, 2, ... but I cannot specify the starting item or the number of items I want to retrieve.

    I made a custom datasource for a listview by implementing IListDataAdapter. I implement the plumbing for turning item index to page number but I end up with an infinite loop calling itemsFromIndex. The first two calls looks good (requesting index 0 and 15), and things get weird after that (a call for index 0 again, and then calls for index 14, part of page 0, forever).

    I double checked with the Bing Search sample and I cannot see my mistake (if any), except that I cannot give as much items as the datasource asked. I could send the code if it could help (the services are available on the web).

    Monday, October 3, 2011 4:42 PM

All replies

  • The main requirement when writing a data adapter is to ensure that you return the item asked for by the index. The countBefore and countAfter are advisory, and so you should be able to map the requested index into one of your pages, and then return all the data for that page.

    A couple of things to verify:

    • You are setting the offset correctly - this is the offset into the array of results of the item at the requested index
    • Your keys are unique, and are strings


    Monday, October 3, 2011 5:09 PM
  • I had trouble with my keys. I solve the problem and things get a lot better !

    However I still have infinite loop problems with the itemsFromIndex callback. It happens randomly when I scroll the listview two fast. When I scroll back its stop the loop, and when I scroll forward again, things start working again. In the meantime I have dozens of service calls.

    It looks like the listview does not like if you do not provide enough items to fullfill the countAfter parameter. I made "by hand" a second call to retrieve all requested items and it worked better, but it's a bit hacky.

    Wednesday, October 5, 2011 7:21 AM
  • I know this is over a year old, but...Just found this thread. I am seeing this issue with incremental loading custom IListDataAdapter all the time. Just when I think it has started working properly, I manage to get it into an infinite loop state. What is the solution to this?

    • Edited by SzymonR Monday, October 22, 2012 6:34 PM
    Monday, October 22, 2012 6:33 PM