Skip to Content

[OData] Get $count result in sapui5 controller

Hello,

In a Sapui5 application, I would like to display total of an OData EntitySet. I can see in Network calls that $count is retrieved in a $batch call :

Header : GET MyEntitySet/$count

Response : 7163

How can I retrieve this value in the controller? I would like to avoid another call of $count.

Thanks for your help.

Cheers,

Sev

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 21, 2017 at 03:55 PM

    assuming the request went via the binding to the table, you need to register for the update finished event for the table or list and in the event handler method, use the below code. check in the debugging once to make sure the code is fine

    oEvent.getParameter("total").

    You might also have to check if the items length is final by using the below code.

    if( this.getView().byId("List").getBinding("items").isLengthFinal() ){ // because this event will be triggered 2 times as far as i remember

    var scount = oEvent.getParameter("total");

    }

    Best Regards,
    Mahesh

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 21, 2017 at 04:14 PM

    Thanks for your answer. I was using this method before, but unfortunately I don't use a sap.m.Table anymore but a sap.ui.table.Table. This component doesn't have updatefinished event.

    Any other way to get total value?

    Best regards,

    Sev

    Add comment
    10|10000 characters needed characters exceeded