Search code examples
sapui5

What is the event for SAPUI5 SmartTable when loading data is failed?


I need to run a code when the smart table cannot read the data from back-end. What kind of event I have to add to the smart table?

For example something like:

oSmartTable.getBinding("items").attachEventOnce("dataFailed", ....

We don't have such an event, but I need something like this.


Solution

  • If we have a SmartTable with a table inside like this, we can use its dataRequested event:

    <smartTable:SmartTable .....  dataRequested="onDataRequested">
      <m:Table id="table" ...>
      ....
      </m:Table>
    </smartTable:SmartTable>
    

    By using this event we try to add dataReceived event of the table:

    onDataRequested: function(oEvent){
        var oTable =  this.byId("table");
        oTable.getBinding("items").attachEventOnce("dataReceived",function(oData) {
            if(!oData.getParameter("data")){
                // Do something here        
            }
        }, this);
    }