Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jul 27, 2017 at 04:44 PM

    $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

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 27, 2017 at 12:25 PM

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

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

    Add comment
    10|10000 characters needed characters exceeded

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

    Hi Ajit,

    Can you share the error from browser's console?

    Thanks,

    Jatin

    Add comment
    10|10000 characters needed characters exceeded