Skip to Content
0

SAPUI5 ODataModel oModel.read() is not working correctly with urlpath?$top=1

Jul 27, 2017 at 10:43 AM

803

avatar image
Former Member
var sPath="/entitytset?$top=1";
oModel.read(sPath,function(oData,response){
alert(oData); \\$top=1 is not working client side page is not working
}));

$count is working.$select is working.

$top=1 is also working if given the url request in browser,the response shows one entry.

Kindly help me.

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

3 Answers

Srikanth KV Jul 27, 2017 at 04:44 PM
1

$top needs to passed differently for "read" operation, below is the syntax.

var sPath = "/entitySet";
oModel.read(sPath, {
    urlParameters: {
        "$top" : 13
    },
    success: function(oData, oResponse){
          alert(oData);
    }
});

In "urlParameters" you can pass $select also, for filters and sort there is a different parameter called filters and sorters

Share
10 |10000 characters needed characters left characters exceeded
Sharath M G Jul 27, 2017 at 12:25 PM
0

What is the error, when you use the filter $top=1?

Does it work if you add the filter as $top=3?

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

It is working in the browser, as a separate url. It is displaying only one row and filtering

But when i use in oModel.read(), it is not working even if i give $top =1 or 3.

0

Check the console - network tab. See the response you get for the triggered service.

0
avatar image
Former Member Jul 27, 2017 at 04:20 PM
0

Hi Ajit,

Can you share the error from browser's console?

Thanks,

Jatin

Share
10 |10000 characters needed characters left characters exceeded