cancel
Showing results for 
Search instead for 
Did you mean: 

ui5 remove default OData param $top and $skip from request

07-09-2021 4:12 PM
3390 views 3 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

In View I use List with items, aber my OData entity not support $top, $skip and $cout params. During request I have error "Not Implemented" and see reques with dafault params: "MessageProcessingLogs('xxxxx')/Attachments?$skip=0&$top=100"

In tag List I use attribut growing="false", but it doesn't help.

I was able to disable the $count parameter using the "defaultCountMode": "None" for model.

How can I disable (change / delete) the $top and $skip parameters?

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

sergei-u-niq
Active Contributor

Hi Andrey,

Basically, OData models are made to work with such operations like sorting or paging server-side. So many controls (like lists) rely on exactly that -- the model will handle that, and odata model handles this serverside. Imagine a List with Millions of Items => you wouldn't want to get them all from the server if your screen will only fit 20 items.

So "correct" way would be to fix your odata service to support top/skip (count is less important in your situation, as it is merely a hint for the binding, to know how many pages to expect)

assuming, you use this service: https://api.sap.com/api/MessageProcessingLogs/resource you should check with SAP to implement top/skip/count

That being said, there are situations, in which you may not have the possibility to fix the service (or not quickly), and would like to work around it. In your situation, I assume, you only have a relatively small list of attachments (not millions), you could (just as idea, I didn't check syntax or anything)

var oAttachmentModel = new sap.ui.model.json.JSONModel(
    "/full/path/to/service/MessageProcessingLogs('xxxxx')/Attachments"
)
yourView.setModel(oAttachmentModel,"attachments")

then you bind the lit against the attachment model, which is a json model, and will handle all the paging (if needed) clientside.

<m:List items="{attachments>/} > ... </m:List>

Hope, this helps,

Sergei

Joseph_BERTHE1
Active Contributor
0 Likes

Hello,

I'm merly agree with Sergei, but I'm not agree with the workaround. I never had a dump because of top/skip implementation. You should look a the entityset implementation, when it is called by an expand.

It would be pity to break the.odata model for too/skip "issue".

Kind regards,

Joseph

sergei-u-niq
Active Contributor
0 Likes

Hi Joseph,

the service is not dumping, it is returning the 501 not implemented error. I think it is quite ok for the service to tell the consumer, that top/skip are not supported rather than silently ignoring them. Returning more than the requested $top elements would probably violate the odata specification (though I didnt check it right now) And ignoring $skip would be semantically wrong: imagine you ask for $top=10,$skip=100 and get the elements 1...10 from server rather than the expected 101..110.

Answers (0)