Forum Stats

  • 3,874,511 Users
  • 2,266,748 Discussions


How to Listen for CollectionDataProvider Fetch Completion

DaveArch Member Posts: 125 Red Ribbon

JET Version: 10.0

Hi Community

I was wondering if anyone knew the best way of finding out when a fetch has been completed by a CollectionDataProvider?

Our use case is to listen for the point at which the fetch from the server is complete and the rows are being loaded into the table.

I see there is the whenReady() function which returns a Promise. This sounds exactly like what we need. Using it, I see the promise resolves before any custom parsing of the data into table rows is complete however I just want to make sure that using this function is the correct approach for the use case.

Many thanks


  • Ben Moroze-Oracle
    Ben Moroze-Oracle Member Posts: 54 Employee

    Better to use the events on the Collection object in the CollectionDataProvider. There is a SYNC event that indicates everything is complete.

  • DaveArch
    DaveArch Member Posts: 125 Red Ribbon

    Hi Community

    We are unable to add event listeners to CollectionDataProvider. The data provider accepts the listener but the function is never called.

    var resolveCollectionSync = function(event){
      console.log("resolveCollectionSync()", event);  
    this.modelCollection = new Model.Collection(null, {
         url: "<url_here>",
         fetchSize: 25
    this.tableCollection = self.modelCollection;
    this.collectionDataProvider = new CollectionDataProvider(self.tableCollection);

    We have also tried passing 'SYNC' and 'ALL' and neither result in the log to the console. Any ideas?

    Jet Version: 10.0

  • Ben Moroze-Oracle
    Ben Moroze-Oracle Member Posts: 54 Employee

    Try adding them directly to the collection object you've passed in and see if those are triggered, not the data provider itself. Those are definitely triggered if the collection goes to fetch.

  • DaveArch
    DaveArch Member Posts: 125 Red Ribbon

    Thanks for your post.

    There does not seem to be a function to add a listener directly to the collection. It details the events that gets fired but it appears that you can only add the listener to the data provider.

    The events that are published by the collection seems central to the functionality so we must be doing something fundamentally wrong.

    Any pointers appreciated.