ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

onLoadMoreItemsRequested called before webservice returned the response #1412

Open punj opened 4 years ago

punj commented 4 years ago

My purpose is for using RadListView is to loads 20 Records from the webservice call at the loading in the RadListView and upon scroll, it should call the web service again and load 20 more records and so on. But, onLoadMoreItemsRequested is calling before the webservice returned the response and therefore the page is loading blank.

onLoadMoreItemsRequested is CALLED BEFORE WEBSERVICE RETURNED THE RESPONSE. SO RADLISTVIEW IS BLANK.

Platform: I am currently running on iOS

ngOnInit() { this.layout = new ListViewLinearLayout(); this.layout.scrollDirection = ListViewScrollDirection.Vertical; // this.initDataItems(); this.handleListProducts(); // Calls the webservice this._changeDetectionRef.detectChanges(); this._dataItems = new ObservableArray(); this.addMoreItemsFromSource(6, null); }

handleListProducts() { this._sourceDataItems = new ObservableArray();

this._searchService.getProductList(1)
  .subscribe(
    data => {
      this.products = data;
      console.log('Data retrieved: ${this.products}' + this.products.length);
      //for(let m=0;m<20;m++){
      for(let i=0;i<this.products.length;i++){
        this._sourceDataItems.push(new DataItem(
          this.products[i].id, 
          (i +1 )+" "+  this.products[i].name,
          this.products[i].title, 
           "Hello",
           "Hello",
           "string"));
      }//
  //  }
    }
  )  

}

public onLoadMoreItemsRequested(args: LoadOnDemandListViewEventData) { console.log("**** onLoadMoreItemsRequested ****"); const that = new WeakRef(this); const listView: RadListView = args.object; if (this._sourceDataItems.length > 0) { setTimeout(function () { that.get().addMoreItemsFromSource(20, listView); }, 0); } else {
args.returnValue = false; listView.notifyAppendItemsOnDemandFinished(0, true); } }


 I really appreciate if you can share us the code which  is using webservice to load the data and then loads the onLoadMoreItemsRequested().

@darind @lini @jordanilchev @rdlauer @etabakov   Thanks in Advance!
felixkrautschuk commented 4 years ago

I can confirm that issue on iOS in our app (NativeScript core, no angular, RadListView 8.1.2). Android is working as expected.

When the request to the webservice starts, the RadListView already calls the onLoadMoreItemsRequested method on iOS. At this moment, there are no dataitems available yet, so

args.returnValue = false;
listView.notifyAppendItemsOnDemandFinished(0, true);

disables the loadOnDemand feature at all.

Even when I try to re-enable it via

setTimeout(function () {
        listview.loadOnDemandMode = rlvModule.ListViewLoadOnDemandMode.Auto;
, 3000);

it has no effect. Scrolling down to the end of the list after the 3 seconds does not call the onLoadMoreItemsRequested method anymore. (Ths also does not work on Android, but it is not necessary for us on Android, because the onLoadMoreItemsRequested is not called immediatly there so the loadOnDemand feature keeps enabled until the user scrolls down and there are no more items available).