locked
Unable to return CountResult.unknown from getCount method of VirtualizedDataSource RRS feed

  • Question

  • Hello, I am implementing VirtualizedDataSource in which total count of items is not known before first page of data items is returned. But returning anything different than positive number and undefined from getCount method of VirtualizedDataSource results in exception - "Error: data adapter should return CountResult.unknown, CountResult.failure, or a non-negative integer for the count." I have traced the error message in ui.js library file to line 7955 and

    if (!isNonNegativeInteger(count) && count !== undefined) {
        throw new WinJS.ErrorFromName("WinJS.UI.ListDataSource.InvalidRequestedCountReturned", strings.invalidRequestedCountReturned);
    }

    It is clear that CountResult enumeration is not considered at all. Beside that CountResult.failure is not defined at all.

    Please do someone know workaround for this?

    Regards, Martin


    • Edited by MDimitrov Friday, July 27, 2012 9:07 AM
    Friday, July 27, 2012 8:07 AM

Answers

  • Correct, return a non-negative integer or undefined.  For your count return a guess of what the number will be.  Subsequent calls to the data source allow you to return the real count.

    Jeff Sanders (MSFT)

    Friday, July 27, 2012 12:15 PM
    Moderator

All replies

  • Correct, return a non-negative integer or undefined.  For your count return a guess of what the number will be.  Subsequent calls to the data source allow you to return the real count.

    Jeff Sanders (MSFT)

    Friday, July 27, 2012 12:15 PM
    Moderator
  • Thanks!

    Initially I implemented it to always return 1, but scrollbar of ListView behave somewhat confusing, so later I decided to run actual data request query (with empty page range) in getCount method.

    I hope this will be fixed in official release.

    Monday, July 30, 2012 8:36 AM