How to know once all odata calls have finished on screen?

I have multiple odata calls on one screen and they are not in a batch call. I want to trigger an event after all the calls have been finished. How do i do so?

23 thoughts on “How to know once all odata calls have finished on screen?”

  1. Add the following code to your model, which will get called each time the model is finished with a request.

    this.getView().getModel().attachRequestCompleted(function(){console.log("complete!");});

    Reply
  2. If you using Tables, you can use the updateFinished event to notify when each read completes.

    <Table headerText="tab1"
            updateFinished="onTableUpdate"
            items="{/Collection}"...
    
         <Table headerText="tab2"
            updateFinished="onTableUpdate"
            items="{/Collection}"...
    
         <Table headerText="tab3"
            updateFinished="onTableUpdate"
            items="{/Collection}"...      
    

    To keep a check you will have to maintain flags when you initialize

    onInit: function () {
            this.oComplete = {
                "tab1" : false,
                "tab2" : false,
                "tab3" : false
            }
    

    And you will need a method which sets these flags to true when each of the tables complete their update.

    onTableUpdate: function(oEvent){
            var oTable= oEvent.getSource(),
                sText = oTable.getHeaderText();
            this.oComplete[sText] = true;
            //Check if all read's are complete
            if(this.oComplete["tab1"] && this.oComplete["tab2"] && this.oComplete["tab3"]){
                this._updateFinished();
            }
    
        },
    
        _updateFinished : function(){
            //Add you logic which should run after all call's complete
            ...
        }
    

    Once it’s all done, _updateFinished will be triggered.

    Note: The updateFinished event works for all controls that extend sap.m.ListBase

    Reply

Leave a Comment