RadListView: loadMoreDataRequested is called multiple time after page load


#1

Hi there,

I’m using NativeScript 3.4 with angular - I have a RadListView in one of my views and for some reason, as soon as the page loads I see that loadMoreDataRequested event handler is called multiple times (actually it’s called again and again until all the data is retrieved from the server) - it is done without any scrolling by the user.

The loadOnDemandMode is set to Auto.

Anyone encountered such a behavior? what am I doing wrong?

Thanks!
Shay.


#2

I have experienced the same behavior. I ended up using a noop as handler until there are items in the list + throttling the handler calls.


#3

Oh no :frowning:
Did you find the root of this problem maybe before going with this workaround?


#4

Could be you’re calling notifyLoadOnDemandFinished too early (in case your ‘load more’ method returns too quickly), or you need to guard it with a silly boolean.

Give this a go, with (loadMoreDataRequested)="loadMore($event)" in the html file:

loadMore(args: ListViewEventData): void {
  // the silly boolean, manipulated by 'loadOrders' below
  if (this.ordersLoading) {
    return;
  }

  const listView: RadListView = args.object;
  setTimeout(() => {
    this.loadOrders(() => listView.notifyLoadOnDemandFinished());
  }, 300);
}

#5

No I did just accept it because it seemed to work just fine. Telerik examples also show usage of some weird timeout. Btw. I’m no longer using RadListView for my list because of lot’s and lot’s of headaches. You can implement load on demand just fine with ListView. It’s not that big of a deal. Also theres a neat pull to refresh plugin. Just in case you end up with similar troubles. Don’t fear implementing all the goodies with ListView. It’s straight forward.