Skip to Content
0

[OData] Get $count result in sapui5 controller

Mar 21, 2017 at 03:28 PM

352

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Mahesh kumar palavalli Mar 21, 2017 at 03:55 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Severin de Beaulieu Mar 21, 2017 at 04:14 PM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Try to attach a event handler for the event: requestCompleted of odata v2 model. you might get the response over there.

Best Regards,
Mahesh

1

Perfect! Thank you.

0

you are most welcome and please mark the question as answered :)

Best Regards,
Mahesh

0