Nativescript: loadMoreItems is called on ListViews items initialization

Created on 24 Apr 2015  路  9Comments  路  Source: NativeScript/NativeScript

_From @qpautrat on April 20, 2015 9:6_

Hi there,

Considering following code:

exports.pageLoaded = function(args) {
    console.log("pageLoaded");

    var page = args.object;

    page.bindingContext = {'items':[{'name':'Foo'},{'name':'Bar'}]};
};

exports.loadMoreItems = function(data) {
    console.log("loadMoreItems");
}

and this view:

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
    <ListView items="{{ items }}" loadMoreItems="loadMoreItems">
        <ListView.itemTemplate>
            <Label text="{{ name }}" />
        </ListView.itemTemplate>
    </ListView>
</Page>

I get:

Apr 20 09:49:28: /app/test.js:3:16: CONSOLE LOG pageLoaded
Apr 20 09:49:28: /app/test.js:11:16: CONSOLE LOG loadMoreItems

However if my items is empty loadMoreItems is not called like it should be.

_Copied from original issue: NativeScript/cross-platform-modules#294_

All 9 comments

Generally loadMoreItems will be called when you scroll ListView to the bottom and when you do not have items you do not have scroll as well.

_From @qpautrat on April 21, 2015 7:3_

Hi @enchev,

I was not specific enough my bad. This happen when i do nothing, no scroll.

+1 for this problem

+1 Any solution for this problem?

Hey @JuanDelgadillo

In case you do not have initial items loaded you won't need loadMoreItem event. Instead just initialize your initial items collection.

Did anyone come up with a viable solution for this? I am experiencing this issue too when I dynamically load in items. It loads <=10 items on the first go, then for what ever reason it loads more even though I did not scroll and am not anywhere near the bottom of the ListView.

I'm taking a stab in the dark here but maybe it's an issue with the rendering of the list? Meaning if it renders each item one by one (which I don't know if it does), I guess at one point it would think it's near the bottom when the first one or two items are loaded?

I confirmed that this is still an issue. If you have a very large array that you're loading from a service using paging (adding 10 items at a time and adding to the existing list on the client side), loadMoreItems is called continuously.

+1,

LoadMoreItems runs automatically whenever items are initiated. Which should not be the behaviour.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings