on 2014 Aug 26 10:56 AM
Hi,
I have a fullscreen view in my Fiori app where we call a oData service through table.bindItems() inside the controller.
The binding of items works fine but we have a situation when we need to display the total number of items (for e.g. 515) on the UI. We do not get this information from the VDM, so we plan to use the length property of the getList() method to determine the total number of items. But because of growing feature of the table it only reads 100 items at a time and the length property returns only 100. I have attached the listener attachRequestCompleted() for the model so that once the bindItems() request is complete i can get the length property. But my problem is that i want the total count.
I saw in the debug that when this table.bindItems() gets called it makes a oData service call and in the response i can see that there is a count property available which has the total number of items (515 for my e.g.) but how do i read this count property from the response inside my controller (probably inside my attachRequestCompleted)?? I would really appreciate any help in this regard. Thanks.
Kind Regards,
Ashish
Tags edited by: Michael Appleby
Request clarification before answering.
Hi,
Set default count mode of Odata Model as Inline.
var sUrl = "gateway/url";
var model = new sap.ui.model.odata.v2.ODataModel(sUrl, true);
model.setDefaultCountMode("Inline");
If the count mode is Inline, then odata will give the results in the below format.
d: {
results:[{},{}],
__count: "1000"
}
__count will be having total records.
Note: Make sure that $count is implemented in the service.
We can retrieve this results in the afterDataRecevied method.
Thanks,
Bhavya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashish,
We are currently facing this issue, did you get any solution how to solve it?
Regards,
Madhuri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not true -- there is certainly a method to get the complete count (i.e. not limited by model maxSize or GrowingList tresholds: retrieve the total length from the binding
For example:
var oBindings = this.getView().getModel().bindList("/Customers");
console.log(oBindings.getLength());
will return the correct total
Hi,
Use setSizeLimit to get the all records.
refer JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.Model
also $count should display the count of records avaialable in OData entity collection for eg. http://services.odata.org/OData/OData.svc/Categories/$count
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Chandra,
Thanks for your suggestions.
But i think in my case we do not want to get the complete list. We still want to get only 100 items initially and then if the user would scroll down he/she would see more items. But we already need to know the total number of items for the purpose of showing a message to the user. For e.g. Total issues (515), but the table would initially show only 100 and then another 100 after scroll. So setting the size litmit to max would not help.
And to be able to use the $count you mentioned, we have to still make another oData service call which we do not want.
But as i mentioned there is already a property named "__count" in the response of the bindItems() method call and i see that it has correct count but not sure how to retrieve it inside the controller. Thanks.
Regards,
Ashish
User | Count |
---|---|
76 | |
29 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.