locked
How does ListView's incremental loadingBehavior combined with custom data source? RRS feed

  • Question

  • I tried "HTML ListView loading behaviors sample" and the incremental loadingBehavior works fine.

    I tried "HTML ListView working with data sources sample", though the Bing search API is a little old, I modified it to request my local web server and the custom dataSource example works fine too.

    then I tried to set the custom data source example to get incremental loadingBehavior:

    // modify div#listview in scenario1.html (data sources sample) to below:

    <div id="listview1" class="box"
        data-win-control="WinJS.UI.ListView"
        data-win-options="{ selectionMode: 'none', tapBehavior: 'none', swipeBehavior: 'none', layout: { type: WinJS.UI.GridLayout },automaticallyLoadPages:true,pagesToLoad: 2, pagesToLoadThreshold: 1, loadingBehavior: 'incremental'}"
    ></div>

    unfortunately it doesn't work. it only display 10 items (2 pages - 20items were expected) and nothing happened.

    I noticed that itemsFromIndex() was called only once, no following requests were made.

    Is there any one had successfully made incremental loadingBehavior combined with custom data source? I need your help, thanks very much!

    Thursday, July 19, 2012 4:11 PM

Answers

  • Hi,

    It seems your project uses a local PHP service, however I am not very familiar with PHP, but when I modified your code to use a dummy internet URL, it returns 100 dummy results in 10 responses. Something like:

                            var items = {};

                                // Data adapter results needs an array of items of the shape:
                                // items =[{ key: key1, data : { field1: value, field2: value, ... }}, { key: key2, data : {...}}, ...];
                                // Form the array of results objects
                                for (var i = 0, itemsLength = 10; i < 10; i++) {
                                    results.push({
                                        key: (fetchIndex + i).toString(),
                                        data: {
                                            title: "a",
                                            thumbnail: "http://...",
                                            width: 300,
                                            height: 200,
                                            linkurl: "http://..."
                                        }
                                    });
                                }
                                // Get the count from the json
                                count = 100;

    The application worked fine, itemFromIndex was called 10 times, and totally 100 items were displayed.

    So please check if the value of count is correct. It represents total value instead of page value. If what I mentioned above doesn't help, it would be better if you can provide a project which uses an ASP.NET service or a cloud service for reproducing the issue on our side.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Monday, July 23, 2012 8:00 AM
    Moderator

All replies

  • I modifed the "HTML ListView loading behaviors sample" to use custom async data source, but I got an error:

    File: ui.js, line: 10517 column: 9

    JavaScript runtime error: Unable to get value of the property 'uniqueID': object is null or undefined.

    I noticed the this thread also metioned the error above. but I still can't figure out what's wrong with it.

    Friday, July 20, 2012 8:48 AM
  • Hi,

    It would be better if you can share your demo project via SkyDrive, so that we can find the issue more conveniently and provide further suggestions for you.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Friday, July 20, 2012 9:50 AM
    Moderator
  • Hi,

    It would be better if you can share your demo project via SkyDrive, so that we can find the issue more conveniently and provide further suggestions for you.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Thanks for your reply. here is my demo project:

    https://skydrive.live.com/redir?resid=CAB55BDF05C7DC2A!134

    you are really really kind-hearted, thanks again.

    Friday, July 20, 2012 11:00 AM
  • Hi,

    It seems your project uses a local PHP service, however I am not very familiar with PHP, but when I modified your code to use a dummy internet URL, it returns 100 dummy results in 10 responses. Something like:

                            var items = {};

                                // Data adapter results needs an array of items of the shape:
                                // items =[{ key: key1, data : { field1: value, field2: value, ... }}, { key: key2, data : {...}}, ...];
                                // Form the array of results objects
                                for (var i = 0, itemsLength = 10; i < 10; i++) {
                                    results.push({
                                        key: (fetchIndex + i).toString(),
                                        data: {
                                            title: "a",
                                            thumbnail: "http://...",
                                            width: 300,
                                            height: 200,
                                            linkurl: "http://..."
                                        }
                                    });
                                }
                                // Get the count from the json
                                count = 100;

    The application worked fine, itemFromIndex was called 10 times, and totally 100 items were displayed.

    So please check if the value of count is correct. It represents total value instead of page value. If what I mentioned above doesn't help, it would be better if you can provide a project which uses an ASP.NET service or a cloud service for reproducing the issue on our side.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Monday, July 23, 2012 8:00 AM
    Moderator
  • Hi,

    I will mark the reply as an answer. If you find it no help, please feel free to unmark it and follow up.

    Thanks.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Monday, July 30, 2012 10:09 AM
    Moderator