locked
Empty Data Adapter RRS feed

  • Question

  • I have implemented the IListDataAdapter interface, wrapped the adapter in a VirtualizedDataSource and display it in a ListView. The adapter notifies about changes in the data by calling notificationHandler.invalidateAll(), and the view is updated accordingly most of the times.

    However, when the data becomes empty, the view is not updated correctly. The data adapter still calls invalidateAll(), subsequent calls to getCount() return 0 and the promises returned from itemsFromIndex() return an error (WinJS.UI.FetchError.doesNotExist).

    I tried calling forceLayout() on the ListView, which caused the layout to become corrupted. Using notificationHandler.reload() instead of invalidateAll() makes the ListView update correctly, but throws a bunch of exceptions on the way (when the data source is trying to use properties of a slot that does not exist) -- so it does not feel right.

    What else can I do to make the view update correctly (i.e. display no items)?

    Thanks,

    Guido

    Thursday, March 1, 2012 4:17 PM

Answers

  • Hi Guido,

    I have been able to do a little research and this is what I found so far:

    InvalidateAll indicates all of the data has been changed but if there is no data this does not get messaged up.  When there is no data reload will talk to the list view.

    Is that enough information for you or do you need more?

    -Jeff


    Jeff Sanders (MSFT)

    Monday, March 5, 2012 9:11 PM
    Moderator

All replies

  • OK, I was calling notificationHandler.reload() from inside itemsFromIndex(). When I do it somewhere else, my view is emptied correctly.

    I'm still wondering why invalidateAll() works in most cases, but reload() is required when the data becomes empty.

    Thursday, March 1, 2012 5:01 PM
  • Hi Guido,

    I have been able to do a little research and this is what I found so far:

    InvalidateAll indicates all of the data has been changed but if there is no data this does not get messaged up.  When there is no data reload will talk to the list view.

    Is that enough information for you or do you need more?

    -Jeff


    Jeff Sanders (MSFT)

    Monday, March 5, 2012 9:11 PM
    Moderator